<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="玖忆;文鹤;博客">
    
    <meta name="author" content="meteor">
    <!-- preconnect -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    
    
    <!--- Seo Part-->
    
    <link rel="canonical" href="https://wait-you.github.io/2023/06/06/docker/"/>
    <meta name="robots" content="index,follow">
    <meta name="googlebot" content="index,follow">
    <meta name="revisit-after" content="1 days">
    
        <meta name="description" content="# Docker  # Docker 概述 # Docker 为什么会出现 一款产品，开发和上线两套环境，应用环境配置费时费力，而且容易出问题 尤其对于机器学习和深度学习的库更是如此，很可能存在版本问题、底层依赖冲突问题 所以发布项目时，不只是一套代码过去，而是代码 + 环境整体打包过去 所谓开发即运维，保证系统稳定性，提高部署效率 使用 Docker 后的流程： 开发：建立模型–环境–打包带上环">
<meta property="og:type" content="article">
<meta property="og:title" content="Docker">
<meta property="og:url" content="https://wait-you.github.io/2023/06/06/Docker/index.html">
<meta property="og:site_name" content="玖忆">
<meta property="og:description" content="# Docker  # Docker 概述 # Docker 为什么会出现 一款产品，开发和上线两套环境，应用环境配置费时费力，而且容易出问题 尤其对于机器学习和深度学习的库更是如此，很可能存在版本问题、底层依赖冲突问题 所以发布项目时，不只是一套代码过去，而是代码 + 环境整体打包过去 所谓开发即运维，保证系统稳定性，提高部署效率 使用 Docker 后的流程： 开发：建立模型–环境–打包带上环">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200606203315597.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200606205436434.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200606205739655.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200606212250845.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200608091950655.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200608092628498.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200608093114774.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616145430166.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616150014082.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616150818860.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616150922549.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616151641013.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616161441669.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616151913277.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616154429105.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616154455964.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616155201285.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616155649476.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616160315298.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616162107363.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616162302653.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616163338187.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616172056530.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616172651835.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616173009473.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616173050756.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616173308194.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616173740981.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200616174440284.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617094339687.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617100948088.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617101105899.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617102049613.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617102126526.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617103406974.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617104004004.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617161744298.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617210554147.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/img/202306051637646.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/img/202306051637636.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/img/202306051637671.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618100621199.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/img/202306051637674.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617213213721.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200617213142079.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618100551587.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618100319796.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618101811914.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618101849917.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618102022167.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618102544564.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618102837397.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618103109004.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618103407205.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618103848104.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618104052242.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618103958168.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618104950722.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618111713885.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618105057785.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618113018622.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618115302656.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618115149971.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618115921069.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618113556445.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618114542622.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618114902169.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618134706491.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618135424706.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618135450037.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618140242423.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618140907894.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618140932621.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618141014511.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618153329894.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618153855605.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618154457286.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618154736475.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618154943194.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618155750591.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618160425265.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618162917672.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618163659503.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618163938466.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618164148642.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618164818624.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618171353336.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618173234347.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618173300551.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618173729692.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618203452205.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/img/202306051637679.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618211547398.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618211516566.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618211803012.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618211023834.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618211318410.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618212936481.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618213310752.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618220658979.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618221801103.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618221837895.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200618222224352.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621165403842.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621165733780.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621170429658.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621170540593.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621171513650.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621172333639.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621172830779.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621174204807.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621174948310.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/171.jpg">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621184333206.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621184847524.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621185539523.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621190219978.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621190439448.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621190524848.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621190812481.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200621192103460.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/img/202306051637698.png">
<meta property="og:image" content="https://wait-you.github.io/%E7%AC%94%E8%AE%B0/Docker.assets/image-20200622075653789.png">
<meta property="og:image" content="http://tuchuang.wenhe9.cn/image-20200622075802180.png">
<meta property="article:published_time" content="2023-06-06T00:37:06.000Z">
<meta property="article:modified_time" content="2023-06-05T08:38:03.694Z">
<meta property="article:author" content="meteor">
<meta property="article:tag" content="Docker">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://tuchuang.wenhe9.cn/image-20200606203315597.png">
    
    
    <!--- Icon Part-->
    <link rel="icon" type="image/png" href="/images/wenhe.png" sizes="192x192">
    <link rel="apple-touch-icon" sizes="180x180" href="/images/wenhe.png">
    <meta name="theme-color" content="#f1404b">
    <link rel="shortcut icon" href="/images/wenhe.png">
    <!--- Page Info-->
    
    <title>
        
            Docker -
        
        玖忆
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    
<link rel="stylesheet" href="/assets/fonts.css">

    <!--- Font Part-->
    
    
    
    

    <!--- Inject Part-->
    
    <script id="hexo-configurations">
    let Global = window.Global || {};
    Global.hexo_config = {"hostname":"wait-you.github.io","root":"/","language":"zh-CN"};
    Global.theme_config = {"articles":{"style":{"font_size":"16px","line_height":1.5,"image_border_radius":"14px","image_alignment":"center","image_caption":false,"link_icon":true},"word_count":{"enable":true,"count":true,"min2read":true},"author_label":{"enable":true,"auto":false,"list":[]},"code_block":{"copy":true,"style":"mac","font":{"enable":false,"family":null,"url":null}},"toc":{"enable":true,"max_depth":3,"number":false,"expand":true,"init_open":true},"copyright":true,"lazyload":true,"recommendation":{"enable":false,"title":"推荐阅读","limit":3,"placeholder":"http://tuchuang.wenhe9.cn/default-bg.jpg","skip_dirs":[]}},"colors":{"primary":"#f1404b","secondary":null},"global":{"fonts":{"chinese":{"enable":false,"family":null,"url":null},"english":{"enable":false,"family":null,"url":null}},"content_max_width":"1000px","sidebar_width":"210px","hover":{"shadow":true,"scale":false},"scroll_progress":{"bar":true,"percentage":true},"busuanzi_counter":{"enable":true,"site_pv":true,"site_uv":true,"post_pv":true},"pjax":true,"open_graph":true,"google_analytics":{"enable":false,"id":null}},"home_banner":{"enable":true,"style":"static","image":{"light":"http://tuchuang.wenhe9.cn/default-bg.jpg","dark":"http://tuchuang.wenhe9.cn/default-bg.jpg"},"title":"玖忆","subtitle":{"text":["我本微末凡尘、可也心向天空"],"hitokoto":{"enable":false,"api":"https://v1.hitokoto.cn"},"typing_speed":100,"backing_speed":80,"starting_delay":500,"backing_delay":1500,"loop":true,"smart_backspace":true},"text_color":{"light":"#fff","dark":"#d1d1b6"},"text_style":{"title_size":"2.8rem","subtitle_size":"1.5rem","line_height":1.2},"custom_font":{"enable":false,"family":null,"url":null},"social_links":{"enable":true,"links":{"github":"https://gitee.com/du-jinliang","instagram":null,"zhihu":null,"twitter":null,"email":"dujinliang9@163.com"}}},"plugins":{"feed":{"enable":false},"aplayer":{"enable":false,"type":"fixed","audios":[{"name":null,"artist":null,"url":null,"cover":null}]},"mermaid":{"enable":false,"version":"9.3.0"}},"version":"2.1.4","navbar":{"auto_hide":true,"color":{"left":"#f78736","right":"#367df7","transparency":35},"links":{"Home":{"path":"/","icon":"fa-regular fa-house"}},"search":{"enable":false,"preload":true}},"page_templates":{"friends_column":2,"tags_style":"blur"},"home":{"sidebar":{"enable":true,"position":"left","first_item":"menu","announcement":null,"links":null},"article_date_format":"auto","categories":{"enable":true,"limit":3},"tags":{"enable":true,"limit":3}}};
    Global.language_ago = {"second":"%s 秒前","minute":"%s 分钟前","hour":"%s 小时前","day":"%s 天前","week":"%s 周前","month":"%s 个月前","year":"%s 年前"};
    Global.data_config = {"masonry":false};
  </script>
    
    <!--- Fontawesome Part-->
    
<link rel="stylesheet" href="/fontawesome/fontawesome.min.css">

    
<link rel="stylesheet" href="/fontawesome/brands.min.css">

    
<link rel="stylesheet" href="/fontawesome/solid.min.css">

    
<link rel="stylesheet" href="/fontawesome/regular.min.css">

    
    
    
    
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
<div class="progress-bar-container">
    
        <span class="scroll-progress-bar"></span>
    

    
        <span class="pjax-progress-bar"></span>
        <span class="pjax-progress-icon">
            <i class="fa-solid fa-circle-notch fa-spin"></i>
        </span>
    
</div>


<main class="page-container">

    

    <div class="main-content-container">

        <div class="main-content-header">
            <header class="navbar-container">
    
    <div class="navbar-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                
                玖忆
                
            </a>
        </div>

        <div class="right">
            <!-- PC -->
            <div class="desktop">
                <ul class="navbar-list">
                    
                        
                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class="" 
                                    href="/"  >
                                    
                                        
                                            <i class="fa-regular fa-house"></i>
                                        
                                        首页
                                    
                                </a>
                                <!-- Submenu -->
                                
                            </li>
                    
                    
                </ul>
            </div>
            <!-- Mobile -->
            <div class="mobile">
                
                <div class="icon-item navbar-bar">
                    <div class="navbar-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- Mobile drawer -->
    <div class="navbar-drawer">
        <ul class="drawer-navbar-list">
            
                
                    <li class="drawer-navbar-item flex-center">
                        <a class="" 
                        href="/"  >
                             
                                
                                    <i class="fa-regular fa-house"></i>
                                
                                首页
                            
                        </a>
                    </li>
                    <!-- Submenu -->
                    
            

        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="main-content-body">

            

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="post-page-container">
        <div class="article-content-container">

            
            
                <div class="article-title">
                    <h1 class="article-title-regular">Docker</h1>
                </div>
            
                
            

            
                <div class="article-header">
                    <div class="avatar">
                        <img src="/images/wenhe.png">
                    </div>
                    <div class="info">
                        <div class="author">
                            <span class="name">meteor</span>
                            
                                <span class="author-label">Lv3</span>
                            
                        </div>
                        <div class="meta-info">
                            <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fa-regular fa-pen-fancy"></i>&nbsp;
        <span class="desktop">2023-06-05 16:37:06</span>
        <span class="mobile">2023-06-05 16:37</span>
        <span class="hover-info">创建</span>
    </span>
    
        <span class="article-date article-meta-item">
            <i class="fa-regular fa-wrench"></i>&nbsp;
            <span class="desktop">2023-06-05 00:38:03</span>
            <span class="mobile">2023-06-05 00:38</span>
            <span class="hover-info">更新</span>
        </span>
    

    
        <span class="article-categories article-meta-item">
            <i class="fa-regular fa-folders"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/categories/%E4%BA%91%E5%8E%9F%E7%94%9F/">云原生</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fa-regular fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/tags/Docker/">Docker</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fa-regular fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                        </div>
                    </div>
                </div>
            

            <div class="article-content markdown-body">
                <h1 id="docker"><a class="markdownIt-Anchor" href="#docker">#</a> Docker</h1>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200606203315597.png"
                      alt="image-20200606203315597"
                ></p>
<h2 id="docker概述"><a class="markdownIt-Anchor" href="#docker概述">#</a> Docker 概述</h2>
<h3 id="docker为什么会出现"><a class="markdownIt-Anchor" href="#docker为什么会出现">#</a> Docker 为什么会出现</h3>
<p>一款产品，开发和上线两套环境，应用环境配置费时费力，而且容易出问题</p>
<p>尤其对于机器学习和深度学习的库更是如此，很可能存在版本问题、底层依赖冲突问题</p>
<p>所以发布项目时，不只是一套代码过去，而是代码 + 环境整体打包过去</p>
<p>所谓开发即运维，保证系统稳定性，提高部署效率</p>
<p>使用 Docker 后的流程：</p>
<p>开发：建立模型–环境–打包带上环境，即镜像–放到 Docker 仓库</p>
<p>部署：下载 Docker 中的镜像，直接运行即可</p>
<p>Docker 的思想来自于集装箱，集装箱，对环境进行隔离</p>
<p>Docker 通过隔离机制，可以将服务器利用到极致。</p>
<h3 id="docker的历史"><a class="markdownIt-Anchor" href="#docker的历史">#</a> Docker 的历史</h3>
<p>2010 年，几个搞 IT 的人，在美国成立一家公司 <code>dotCloud</code></p>
<p>做一些 pass 的云计算服务</p>
<p>他们将自己的容器化技术命名为 Docker</p>
<p>Docker 基于 Go 语言开发</p>
<p>Docker 刚刚诞生的时候，没有引起行业的注意，dotCloud 活不下去</p>
<p>然后他们决定开源</p>
<p>2013 年，创始人将 Docker 开源，不开则以，一开惊人，刚开源的时候，每个月都会更新一个版本</p>
<p>2014 年 4 月 9 日，Docker 1.0 发布</p>
<h3 id="容器vs虚拟机"><a class="markdownIt-Anchor" href="#容器vs虚拟机">#</a> 容器 vs 虚拟机</h3>
<p>在容器技术出来之前，用的是虚拟机技术</p>
<h4 id="虚拟机原理示意图"><a class="markdownIt-Anchor" href="#虚拟机原理示意图">#</a> 虚拟机原理示意图</h4>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200606205436434.png"
                      alt="image-20200606205436434"
                ></p>
<p>缺点：</p>
<ol>
<li>资源占用多</li>
<li>冗余步骤多</li>
<li>启动很慢</li>
</ol>
<h4 id="容器化技术示意图"><a class="markdownIt-Anchor" href="#容器化技术示意图">#</a> 容器化技术示意图</h4>
<p>不是模拟的完整的操作系统</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200606205739655.png"
                      alt="image-20200606205739655"
                ></p>
<h4 id="二者对比"><a class="markdownIt-Anchor" href="#二者对比">#</a> 二者对比</h4>
<p>比较虚拟机和 Docker 的不同</p>
<table>
<thead>
<tr>
<th></th>
<th>传统虚拟机</th>
<th>Docker</th>
</tr>
</thead>
<tbody>
<tr>
<td>虚拟内容</td>
<td>硬件 + 完整的操作系统 + 软件</td>
<td>APP+LIB</td>
</tr>
<tr>
<td>大小</td>
<td>笨重，通常几个 G</td>
<td>轻便几个 M 或 KB</td>
</tr>
<tr>
<td>启动速度</td>
<td>慢，分钟级</td>
<td>快，秒级</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="docker安装"><a class="markdownIt-Anchor" href="#docker安装">#</a> Docker 安装</h2>
<h3 id="docker的基本组成"><a class="markdownIt-Anchor" href="#docker的基本组成">#</a> Docker 的基本组成</h3>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200606212250845.png"
                      alt="image-20200606212250845"
                ></p>
<p>明确几个概念：</p>
<ol>
<li>
<p>镜像 (image)：docker 镜像好比一个模板，可以通过这个模板来创建容器 (container)，一个镜像可以创建多个容器，类似 Python 中的 Class</p>
</li>
<li>
<p>容器 (container)：类似 Python 中通过 Class 创建的实例，Object；容器可以理解为一个简易的系统</p>
</li>
<li>
<p>仓库 (repository)：存放镜像的地方，</p>
<p>分为共有仓库和私有仓库</p>
<ul>
<li>
<p>Docker Hub：国外的</p>
</li>
<li>
<p>阿里云：配置镜像加速</p>
</li>
</ul>
</li>
</ol>
<h3 id="环境准备"><a class="markdownIt-Anchor" href="#环境准备">#</a> 环境准备</h3>
<p>我们要有一台服务器，并且可以操作它</p>
<ol>
<li>Linux 命令基础，购买 linux 阿里云的服务器</li>
<li>CentOS 7</li>
<li>使用 Xshell 链接远程服务器</li>
</ol>
<h3 id="安装xshell"><a class="markdownIt-Anchor" href="#安装xshell">#</a> 安装 xshell</h3>
<p>下载 CentOS7 <a class="link"   target="_blank" rel="noopener" href="https://www.jianshu.com/p/a63f47e096e8" >https://www.jianshu.com/p/a63f47e096e8 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p>下载 VMware 360 软件管家下载</p>
<p>VMware 配置虚拟机 <a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/babyxue/article/details/80970526" >https://blog.csdn.net/babyxue/article/details/80970526 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p>xshell 链接服务器 <a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/zzy1078689276/article/details/77280814" >https://blog.csdn.net/zzy1078689276/article/details/77280814 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# cd /</span><br><span class="line">[root@192 /]# pwd</span><br><span class="line">/</span><br><span class="line">[root@192 /]# ls</span><br><span class="line">bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var</span><br><span class="line">[root@192 /]# uname -r</span><br><span class="line">3.10.0-1127.el7.x86_64</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200608091950655.png"
                      alt="image-20200608091950655"
                ></p>
<p>用户名</p>
<p>密码</p>
<p>查看 ip：vmware 里面输入，ip addIPr</p>
<p><a class="link"   target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1og4y1q7M4?p=6" >https://www.bilibili.com/video/BV1og4y1q7M4?p=6 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<h3 id="centos安装"><a class="markdownIt-Anchor" href="#centos安装">#</a> Centos 安装</h3>
<p><a class="link"   target="_blank" rel="noopener" href="https://docs.docker.com/engine/install/centos/" >https://docs.docker.com/engine/install/centos/ <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<h3 id="卸载旧的版本"><a class="markdownIt-Anchor" href="#卸载旧的版本">#</a> 卸载旧的版本</h3>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"># 卸载旧的版本</span><br><span class="line">$ sudo yum remove docker \</span><br><span class="line">                  docker-client \</span><br><span class="line">                  docker-client-latest \</span><br><span class="line">                  docker-common \</span><br><span class="line">                  docker-latest \</span><br><span class="line">                  docker-latest-logrotate \</span><br><span class="line">                  docker-logrotate \</span><br><span class="line">                  docker-engine</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200608092628498.png"
                      alt="image-20200608092628498"
                ></p>
<h3 id="安装基本环境"><a class="markdownIt-Anchor" href="#安装基本环境">#</a> 安装基本环境</h3>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 安装基本的安装包</span><br><span class="line">$ sudo yum install -y yum-utils</span><br></pre></td></tr></table></figure></div>
<p>!</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200608093114774.png"
                      alt="image-20200608093114774"
                ></p>
<h3 id="设置镜像的仓库"><a class="markdownIt-Anchor" href="#设置镜像的仓库">#</a> 设置镜像的仓库</h3>
<p>注意！！下载默认用国外的，太慢不要用！</p>
<p>用国内镜像，百度搜索，docker 的阿里云镜像地址</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"># 不要用官网默认这个！</span><br><span class="line">$ sudo yum-config-manager \</span><br><span class="line">    --add-repo \</span><br><span class="line">    https://download.docker.com/linux/centos/docker-ce.repo # 默认是国外的</span><br><span class="line"></span><br><span class="line"># 换成下面的</span><br><span class="line"></span><br><span class="line">$ sudo yum-config-manager \</span><br><span class="line">    --add-repo \</span><br><span class="line">    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 阿里云镜像</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616145430166.png"
                      alt="image-20200616145430166"
                ></p>
<p>直接复制粘贴就 OK 了</p>
<p>更像软件包索引</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum makecache fast</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616150014082.png"
                      alt="image-20200616150014082"
                ></p>
<p>没有问题的话就是可以用的</p>
<h3 id="安装docker引擎"><a class="markdownIt-Anchor" href="#安装docker引擎">#</a> 安装 docker 引擎</h3>
<div class="highlight-container" data-rel="Python"><figure class="iseeu highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install docker-ce docker-ce-cli containerd.io <span class="comment"># docker-ce 社区版 ee 企业版</span></span><br></pre></td></tr></table></figure></div>
<p>注意这里会有几个个 y/n 的判断</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616150818860.png"
                      alt="image-20200616150818860"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616150922549.png"
                      alt="image-20200616150922549"
                ></p>
<p>要看到 Complet 再收手！</p>
<h3 id="启动docker"><a class="markdownIt-Anchor" href="#启动docker">#</a> 启动 Docker</h3>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl start docker # 代表启动成功</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker version</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">Client: Docker Engine - Community</span><br><span class="line"> Version:           19.03.11</span><br><span class="line"> API version:       1.40</span><br><span class="line"> Go version:        go1.13.10</span><br><span class="line"> Git commit:        42e35e61f3</span><br><span class="line"> Built:             Mon Jun  1 09:13:48 2020</span><br><span class="line"> OS/Arch:           linux/amd64</span><br><span class="line"> Experimental:      false</span><br><span class="line"></span><br><span class="line">Server: Docker Engine - Community</span><br><span class="line"> Engine:</span><br><span class="line">  Version:          19.03.11</span><br><span class="line">  API version:      1.40 (minimum version 1.12)</span><br><span class="line">  Go version:       go1.13.10</span><br><span class="line">  Git commit:       42e35e61f3</span><br><span class="line">  Built:            Mon Jun  1 09:12:26 2020</span><br><span class="line">  OS/Arch:          linux/amd64</span><br><span class="line">  Experimental:     false</span><br><span class="line"> containerd:</span><br><span class="line">  Version:          1.2.13</span><br><span class="line">  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429</span><br><span class="line"> runc:</span><br><span class="line">  Version:          1.0.0-rc10</span><br><span class="line">  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd</span><br><span class="line"> docker-init:</span><br><span class="line">  Version:          0.18.0</span><br><span class="line">  GitCommit:        fec3683</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run hello-world</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616151641013.png"
                      alt="image-20200616151641013"
                ></p>
<p>中间一堆是签名信息</p>
<p>run 的运行流程图</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616161441669.png"
                      alt="image-20200616161441669"
                ></p>
<p>查看下载的镜像</p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616151913277.png"
                      alt="image-20200616151913277"
                ></p>
<h3 id="卸载docker"><a class="markdownIt-Anchor" href="#卸载docker">#</a> 卸载 Docker</h3>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 卸载依赖</span><br><span class="line">yum remove docker-ce docker-ce-cli containerd.io</span><br><span class="line"></span><br><span class="line"># 删除资源</span><br><span class="line">rm -rf /var/lib/docker # docker 的默认工作路径</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h3 id="阿里云镜像加速"><a class="markdownIt-Anchor" href="#阿里云镜像加速">#</a> 阿里云镜像加速</h3>
<p>支付宝扫码登录，短信验证，确认授权</p>
<p>我有两个问题</p>
<ol>
<li>
<p>阿里云镜像加速必须配置嘛？</p>
<blockquote>
<p>哎呦我去：加速快</p>
<p>哎呦我去：要是翻墙就无所谓了</p>
</blockquote>
</li>
<li>
<p>这个阿里云必须要买嘛，买哪个，我看阿里云好多产品</p>
<blockquote>
<p>哎呦我去：不需要买</p>
<p>哎呦我去：免费的</p>
<p>哎呦我去：阿里云搜索容器服务</p>
<p>哎呦我去：有一个镜像加速</p>
</blockquote>
</li>
<li>
<p>这个地址是哪来的呀</p>
</li>
</ol>
<p>操作</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616154429105.png"
                      alt="image-20200616154429105"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616154455964.png"
                      alt="image-20200616154455964"
                ></p>
<p>控制台搜索 容器镜像服务</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616155201285.png"
                      alt="image-20200616155201285"
                ></p>
<p>找到加速地址</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616155649476.png"
                      alt="image-20200616155649476"
                ></p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">sudo mkdir -p /etc/docker # 创建一个陌路</span><br><span class="line">sudo tee /etc/docker/daemon.json &lt;&lt;-&#x27;EOF&#x27;</span><br><span class="line">&#123;</span><br><span class="line">  &quot;registry-mirrors&quot;: [&quot;https://uyfgafsw.mirror.aliyuncs.com&quot;]</span><br><span class="line">&#125;</span><br><span class="line">EOF # 编写配置文件</span><br><span class="line"></span><br><span class="line">sudo systemctl daemon-reload # 重启服务</span><br><span class="line">sudo systemctl restart docker # 重启docker</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616160315298.png"
                      alt="image-20200616160315298"
                ></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://www.processon.com/" >在线画图软件 ProcessOn <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV177411K7bH" >服务器及购买相关介绍 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<h2 id="底层原理"><a class="markdownIt-Anchor" href="#底层原理">#</a> 底层原理</h2>
<p>Docker 是真么工作的？</p>
<p>Docker 是一个 Client-Server 结构的系统，Docker 的守护进程在主机上。通过 Socket 从客户端访问！</p>
<p>DockerServer 接受到 Docker-Client 的指令，</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616162107363.png"
                      alt="image-20200616162107363"
                ></p>
<p>Docker 为什么比 VM 快？</p>
<ol>
<li>Docker 有着比虚拟机更少的抽象层</li>
<li>docker 主要用的是宿主机的内核，vm 需要 Guest OS</li>
</ol>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616162302653.png"
                      alt="image-20200616162302653"
                ></p>
<p>所以说新建一个容器的时候，docker 不需要像虚拟机一样重新加载一个操作系统内核，避免引导</p>
<h2 id="docker命令"><a class="markdownIt-Anchor" href="#docker命令">#</a> Docker 命令</h2>
<h3 id="帮助命令"><a class="markdownIt-Anchor" href="#帮助命令">#</a> 帮助命令</h3>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">docker version # 显示docker的基本信息</span><br><span class="line">docker info # 系统信息，镜像和容器的数量</span><br><span class="line">docker 命令 --help # 全部信息</span><br></pre></td></tr></table></figure></div>
<p><a class="link"   target="_blank" rel="noopener" href="https://docs.docker.com/reference/" >官网文档 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616163338187.png"
                      alt="image-20200616163338187"
                ></p>
<h3 id="镜像命令"><a class="markdownIt-Anchor" href="#镜像命令">#</a> 镜像命令</h3>
<h4 id="docker-images"><a class="markdownIt-Anchor" href="#docker-images">#</a> docker images</h4>
<p>查看所有本地主机上的镜像</p>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]<span class="comment"># docker images</span></span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616172056530.png"
                      alt="image-20200616172056530"
                ></p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 解释</span><br><span class="line">REPOSITORY  # 镜像仓库源</span><br><span class="line">TAG                 # 镜像的标签</span><br><span class="line">IMAGE ID           # 镜像的ID</span><br><span class="line">CREATED           # 镜像的创建时间</span><br><span class="line">SIZE # 镜像的大小</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">--all , -a		Show all images (default hides intermediate images) <span class="comment"># 显示所有</span></span><br><span class="line">--digests		Show digests</span><br><span class="line">--filter , -f		Filter output based on conditions provided</span><br><span class="line">--format		Pretty-<span class="built_in">print</span> images using a Go template</span><br><span class="line">--no-trunc		Don’t <span class="built_in">truncate</span> output</span><br><span class="line">--quiet , -q		Only show numeric IDs <span class="comment"># 只显示id</span></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616172651835.png"
                      alt="image-20200616172651835"
                ></p>
<h4 id="docker-search"><a class="markdownIt-Anchor" href="#docker-search">#</a> docker search</h4>
<p>搜索仓库中的镜像，相当于网页搜索</p>
<p><a class="link"   target="_blank" rel="noopener" href="http://hub.docker.com" >网页搜索 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616173009473.png"
                      alt="image-20200616173009473"
                ></p>
<p>mysql</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616173050756.png"
                      alt="image-20200616173050756"
                ></p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search mysql</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616173308194.png"
                      alt="image-20200616173308194"
                ></p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search --help</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616173740981.png"
                      alt="image-20200616173740981"
                ></p>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 解释</span></span><br><span class="line">Options:</span><br><span class="line">  -f, --filter filter   Filter output based on conditions provided</span><br><span class="line">      --format string   Pretty-<span class="built_in">print</span> search using a Go template</span><br><span class="line">      --<span class="built_in">limit</span> int       Max number of search results (default 25)</span><br><span class="line">      --no-trunc        Don<span class="string">&#x27;t truncate output</span></span><br><span class="line"><span class="string"></span></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search mysql --filter=STARS=3000 # 搜索出Stars大于3000的</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200616174440284.png"
                      alt="image-20200616174440284"
                ></p>
<h4 id="docker-pull"><a class="markdownIt-Anchor" href="#docker-pull">#</a> docker pull</h4>
<p>下载镜像</p>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull mysql <span class="comment"># 下载mysql镜像，default tag，默认最新版latest</span></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]<span class="comment"># sudo systemctl daemon-reload</span></span><br><span class="line">[root@192 ~]<span class="comment"># sudo systemctl restart docker</span></span><br><span class="line">[root@192 ~]<span class="comment"># docker pull mysql</span></span><br><span class="line">Using default tag: latest <span class="comment"># 不写tag默认最新版</span></span><br><span class="line">latest: Pulling from library/mysql</span><br><span class="line">8559a31e96f4: Pull complete  <span class="comment"># layer 分层下载，docker image的核心 联合文件系统</span></span><br><span class="line">d51ce1c2e575: Pull complete </span><br><span class="line">c2344adc4858: Pull complete </span><br><span class="line">fcf3ceff18fc: Pull complete </span><br><span class="line">16da0c38dc5b: Pull complete </span><br><span class="line">b905d1797e97: Pull complete </span><br><span class="line">4b50d1c6b05c: Pull complete </span><br><span class="line">c75914a65ca2: Pull complete </span><br><span class="line">1ae8042bdd09: Pull complete </span><br><span class="line">453ac13c00a3: Pull complete </span><br><span class="line">9e680cd72f08: Pull complete </span><br><span class="line">a6b5dc864b6c: Pull complete </span><br><span class="line">Digest: sha256:8b7b328a7ff6de46ef96bcf83af048cb00a1c86282bfca0cb119c84568b4caf6<span class="comment">#签名</span></span><br><span class="line">Status: Downloaded newer image <span class="keyword">for</span> mysql:latest</span><br><span class="line">docker.io/library/mysql:latest <span class="comment"># 真实地址</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 即</span></span><br><span class="line">docker pull mysql</span><br><span class="line"><span class="comment"># 等价于</span></span><br><span class="line">docker pull docker.io/library/mysql:latest</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 指定版本下载 </span></span><br><span class="line">docker pull mysql:5.7</span><br></pre></td></tr></table></figure></div>
<p>版本来自于官网，版本库<a class="link"   target="_blank" rel="noopener" href="https://hub.docker.com/_/mysql" > https://hub.docker.com/_/mysql <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617094339687.png"
                      alt="image-20200617094339687"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617100948088.png"
                      alt="image-20200617100948088"
                ></p>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br></pre></td></tr></table></figure></div>
<p>此时查看镜像，可以看到新下载的两个</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617101105899.png"
                      alt="image-20200617101105899"
                ></p>
<h4 id="docker-rmi"><a class="markdownIt-Anchor" href="#docker-rmi">#</a> docker rmi</h4>
<p>remove images</p>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 删除一个 可以通过名称 也可以指定id -f表示删除所有</span></span><br><span class="line">docker rmi -f 9cfcce23593a</span><br><span class="line"><span class="comment"># 删除多个 用空格分隔id</span></span><br><span class="line">docker rmi -f <span class="built_in">id</span> <span class="built_in">id</span> <span class="built_in">id</span></span><br><span class="line"><span class="comment"># 删除所有 </span></span><br><span class="line">docker rmi -f $(docker images -aq) <span class="comment"># images -aq就是查所有镜像id，从而递归删除</span></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617102049613.png"
                      alt="image-20200617102049613"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617102126526.png"
                      alt="image-20200617102126526"
                ></p>
<h3 id="容器命令"><a class="markdownIt-Anchor" href="#容器命令">#</a> 容器命令</h3>
<p>说明：有了镜像才能创建容器，linux，下载一个 centos 镜像来测试学习</p>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull centos</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617103406974.png"
                      alt="image-20200617103406974"
                ></p>
<h4 id="新建容器并启动"><a class="markdownIt-Anchor" href="#新建容器并启动">#</a> 新建容器并启动</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">docker run [可选参数] image</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">参数说明</span></span><br><span class="line">--name=“Name” # 容器名字，用于区分容器</span><br><span class="line">-d 后台方式运行</span><br><span class="line">-it 使用交互方式运行，进入容器查看内容</span><br><span class="line">-p 指定容器的端口 如-p 8080::8080</span><br><span class="line">	-p ip:主机端口：容器端口</span><br><span class="line">	-p 主机端口:容器端口</span><br><span class="line">	-p 容器端口</span><br><span class="line">	</span><br><span class="line">-p 随机指定端口</span><br></pre></td></tr></table></figure></div>
<h4 id="进入退出容器"><a class="markdownIt-Anchor" href="#进入退出容器">#</a> 进入退出容器</h4>
<div class="highlight-container" data-rel="Bash"><figure class="iseeu highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 进入</span></span><br><span class="line">docker run -it centos /bin/bash </span><br><span class="line"><span class="comment"># 查看目录</span></span><br><span class="line"><span class="built_in">ls</span></span><br><span class="line"><span class="comment"># 退出</span></span><br><span class="line"><span class="built_in">exit</span></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617104004004.png"
                      alt="image-20200617104004004"
                ></p>
<p>注意这里面主机名，编程了 centos 的 id</p>
<p>这里面就是一个容器，套娃啊</p>
<h4 id="查看运行的容器"><a class="markdownIt-Anchor" href="#查看运行的容器">#</a> 查看运行的容器</h4>
<div class="highlight-container" data-rel="Plaintext"><figure class="iseeu highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"># 查看正在运行的容器</span><br><span class="line">docker ps</span><br><span class="line"># 查看曾经运行的容器</span><br><span class="line">docker ps -a</span><br><span class="line"># 显示最近创建的容器，设置显示个数</span><br><span class="line">docker ps -a - n=? </span><br><span class="line"># 只显示容器的编号</span><br><span class="line">docker ps -aq</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line">[root@192 ~]# docker ps -a</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES</span><br><span class="line">9939864fa2e6        centos              &quot;bin/bash&quot;          4 minutes ago       Exited (0) 4 minutes ago                       unruffled_knuth</span><br><span class="line">5f42e9930435        centos              &quot;/bin/bash&quot;         8 minutes ago       Exited (0) 4 minutes ago                       lucid_cannon</span><br><span class="line">a89ddb393d3d        bf756fb1ae65        &quot;/hello&quot;            19 hours ago        Exited (0) 19 hours ago                        gracious_bhabha</span><br><span class="line">[root@192 ~]# docker ps -a -n=2</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES</span><br><span class="line">9939864fa2e6        centos              &quot;bin/bash&quot;          6 minutes ago       Exited (0) 6 minutes ago                       unruffled_knuth</span><br><span class="line">5f42e9930435        centos              &quot;/bin/bash&quot;         10 minutes ago      Exited (0) 7 minutes ago </span><br><span class="line">[root@192 ~]# docker ps -aq</span><br><span class="line">9939864fa2e6</span><br><span class="line">5f42e9930435</span><br><span class="line">a89ddb393d3d</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="退出容器"><a class="markdownIt-Anchor" href="#退出容器">#</a> 退出容器</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">容器停止退出</span></span><br><span class="line">exit</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">容器不停止退出 注意必须在英文输入法下，中文输入法不行</span></span><br><span class="line">Ctrl + P + Q</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker run -it centos /bin/bash</span><br><span class="line">[root@bfcea13c40cd /]# [root@192 ~]# docker ps ##注意这里会自动给个命令，删掉</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES</span><br><span class="line">bfcea13c40cd        centos              &quot;/bin/bash&quot;         About a minute ago   Up About a minute                       stoic_wilson</span><br><span class="line">edbd9366d959        centos              &quot;/bin/bash&quot;         7 minutes ago        Up 7 minutes                            affectionate_bartik</span><br><span class="line">[root@192 ~]# docker exec -it edbd9366d959 /bin/bash ## 再次进入</span><br><span class="line">[root@edbd9366d959 /]# exit ##停止并推出</span><br><span class="line">exit</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="删除容器"><a class="markdownIt-Anchor" href="#删除容器">#</a> 删除容器</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除指定容器 不能删除正在运行的容器，如果强制删除 <span class="built_in">rm</span> -f</span></span><br><span class="line">docker rm 容器id</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除所有容器</span></span><br><span class="line">docker rm -f $(docker ps -aq)</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">删除所有容器</span></span><br><span class="line">docker ps -a -q|xargs docker rm</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker ps -a</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES</span><br><span class="line">bfcea13c40cd        centos              &quot;/bin/bash&quot;         29 minutes ago      Up 29 minutes                                   stoic_wilson</span><br><span class="line">edbd9366d959        centos              &quot;/bin/bash&quot;         35 minutes ago      Up 35 minutes                                   affectionate_bartik</span><br><span class="line">9939864fa2e6        centos              &quot;bin/bash&quot;          48 minutes ago      Exited (0) 48 minutes ago                       unruffled_knuth</span><br><span class="line">5f42e9930435        centos              &quot;/bin/bash&quot;         52 minutes ago      Exited (0) 49 minutes ago                       lucid_cannon</span><br><span class="line">a89ddb393d3d        bf756fb1ae65        &quot;/hello&quot;            20 hours ago        Exited (0) 20 hours ago                         gracious_bhabha</span><br><span class="line">[root@192 ~]# docker rm 5f42e9930435</span><br><span class="line">5f42e9930435</span><br><span class="line">[root@192 ~]# docker rm edbd9366d959      # 注意正在运行的容器不能删除</span><br><span class="line">Error response from daemon: You cannot remove a running container edbd9366d9596c744dd449119269b04de2f2a494e7fc471f6396bcefd94c33fe. Stop the container before attempting removal or force remove</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker ps -aq # 所有容器id</span><br><span class="line">bfcea13c40cd</span><br><span class="line">edbd9366d959</span><br><span class="line">9939864fa2e6</span><br><span class="line">a89ddb393d3d</span><br><span class="line">[root@192 ~]# docker rm -f $(docker ps -aq) # 全部删除</span><br><span class="line">bfcea13c40cd</span><br><span class="line">edbd9366d959</span><br><span class="line">9939864fa2e6</span><br><span class="line">a89ddb393d3d</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="启动和停止容器的操作"><a class="markdownIt-Anchor" href="#启动和停止容器的操作">#</a> 启动和停止容器的操作</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker start</span><br><span class="line">docker restart</span><br><span class="line">docker stop</span><br><span class="line">docker kill</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker run -it centos /bin/bash</span><br><span class="line">[root@7b1a7dd10ea4 /]# exit</span><br><span class="line">exit</span><br><span class="line">[root@192 ~]# docker ps #查看正在运行的</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line">[root@192 ~]# docker ps -a # 查看历史运行过的</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES</span><br><span class="line">7b1a7dd10ea4        centos              &quot;/bin/bash&quot;         54 seconds ago      Exited (0) 42 seconds ago                       fervent_mirzakhani</span><br><span class="line">[root@192 ~]# docker start 7b1a7dd10ea4 # 启动当前这个容器 container id 粘过 来</span><br><span class="line">7b1a7dd10ea4</span><br><span class="line">[root@192 ~]# docker ps # 查看当前运行容器 发现启动成功</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line">7b1a7dd10ea4        centos              &quot;/bin/bash&quot;         2 minutes ago       Up 28 seconds                           fervent_mirzakhani</span><br><span class="line">[root@192 ~]# docker stop 7b1a7dd10ea4 # 停止运行</span><br><span class="line">7b1a7dd10ea4</span><br><span class="line">[root@192 ~]# docker ps # 再次查看 没有这个容器了</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h3 id="常用其他命令"><a class="markdownIt-Anchor" href="#常用其他命令">#</a> 常用其他命令</h3>
<h4 id="后台启动docker"><a class="markdownIt-Anchor" href="#后台启动docker">#</a> 后台启动 docker</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker run -d 镜像名</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">用docker ps 查看的时候 发现停止了</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">后台运行，docker发现前台没有，容器启动后，发现自己没有提供服务，会立刻停止</span></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">Last login: Wed Jun 17 19:47:35 2020</span><br><span class="line">[root@192 ~]# systemctl start docker # 关机后重启了，需要启动docker</span><br><span class="line">[root@192 ~]# docker run -d centos # 运行</span><br><span class="line">8ce188e5fee31c2fac93c0a405ee1a95c38dbc50cb47c35b19c0039c27558ded</span><br><span class="line">[root@192 ~]# docker ps -a # 查看正在运行的</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES</span><br><span class="line">8ce188e5fee3        centos              &quot;/bin/bash&quot;         19 seconds ago      Exited (0) 18 seconds ago                       tender_dirac</span><br><span class="line">7b1a7dd10ea4        centos              &quot;/bin/bash&quot;         8 hours ago         Exited (0) 8 hours ago                          fervent_mirzakhani</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="查看日志"><a class="markdownIt-Anchor" href="#查看日志">#</a> 查看日志</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">docker logs</span><br><span class="line">docker logs -f -t --tail n 【id】</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617161744298.png"
                      alt="image-20200617161744298"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker logs --help</span><br><span class="line"></span><br><span class="line">Usage:	docker logs [OPTIONS] CONTAINER</span><br><span class="line"></span><br><span class="line">Fetch the logs of a container</span><br><span class="line"></span><br><span class="line">Options:</span><br><span class="line">      --details        Show extra details provided to logs</span><br><span class="line">  -f, --follow         Follow log output</span><br><span class="line">      --since string   Show logs since timestamp (e.g.</span><br><span class="line">                       2013-01-02T13:23:37) or relative</span><br><span class="line">                       (e.g. 42m for 42 minutes)</span><br><span class="line">      --tail string    Number of lines to show from the</span><br><span class="line">                       end of the logs (default &quot;all&quot;)</span><br><span class="line">  -t, --timestamps     Show timestamps # 时间戳</span><br><span class="line">      --until string   Show logs before a timestamp (e.g.</span><br><span class="line">                       2013-01-02T13:23:37) or relative</span><br><span class="line">                       (e.g. 42m for 42 minutes)</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">whiel true;do echo shenzai;sleep </span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">运行一个</span></span><br><span class="line">[root@192 ~]# docker run -it centos /bin/bash</span><br><span class="line"></span><br><span class="line">[root@c2887d35c71d /]# [root@192 ~]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line">c2887d35c71d        centos              &quot;/bin/bash&quot;         57 seconds ago      Up 56 seconds                           vigorous_kare</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看日志，由于没有运行脚本，所以啥也没显示</span></span><br><span class="line">[root@192 ~]# docker logs -f -t --tail 10 c2887d35c71d</span><br><span class="line">^C # ctrl+c退出</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">运行centos里面加个脚本</span></span><br><span class="line">[root@192 ~]# docker run -d centos /bin/sh -c &quot;while true;do echo shenzai;sleep 1;done&quot;</span><br><span class="line">cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388</span><br><span class="line"></span><br><span class="line">[root@192 ~]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES</span><br><span class="line">cb6d7fbc3f27        centos              &quot;/bin/sh -c &#x27;while t…&quot;   7 seconds ago       Up 6 seconds                            dreamy_almeida</span><br><span class="line">c2887d35c71d        centos              &quot;/bin/bash&quot;              3 minutes ago       Up 3 minutes                            vigorous_kare</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看日志 发现隔一秒打印一条</span></span><br><span class="line">[root@192 ~]# docker logs -f -t --tail 10 cb6d7fbc3f27</span><br><span class="line">2020-06-17T12:02:11.293765084Z shenzai</span><br><span class="line">2020-06-17T12:02:12.297675608Z shenzai</span><br><span class="line">2020-06-17T12:02:13.301845582Z shenzai</span><br><span class="line">2020-06-17T12:02:14.304800996Z shenzai</span><br><span class="line">2020-06-17T12:02:15.307130238Z shenzai</span><br><span class="line">2020-06-17T12:02:16.310574235Z shenzai</span><br><span class="line">2020-06-17T12:02:17.312946923Z shenzai</span><br><span class="line">2020-06-17T12:02:18.314841295Z shenzai</span><br><span class="line">2020-06-17T12:02:19.317021705Z shenzai</span><br><span class="line">2020-06-17T12:02:20.319670013Z shenzai</span><br><span class="line">2020-06-17T12:02:21.322651649Z shenzai</span><br><span class="line">2020-06-17T12:02:22.325466918Z shenzai</span><br><span class="line">2020-06-17T12:02:23.327984704Z shenzai</span><br><span class="line">2020-06-17T12:02:24.329656919Z shenzai</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="查看正在运行的容器信息"><a class="markdownIt-Anchor" href="#查看正在运行的容器信息">#</a> 查看正在运行的容器信息</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br></pre></td><td class="code"><pre><span class="line">[root@192 ~]# docker inspect cb6d7fbc3f27</span><br><span class="line">[</span><br><span class="line">    &#123;</span><br><span class="line">        # 容器的完整id</span><br><span class="line">        &quot;Id&quot;: &quot;cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388&quot;,</span><br><span class="line">        </span><br><span class="line">        # 创建时间</span><br><span class="line">        &quot;Created&quot;: &quot;2020-06-17T12:00:50.706906186Z&quot;,</span><br><span class="line">        </span><br><span class="line">        # 脚本位置</span><br><span class="line">        &quot;Path&quot;: &quot;/bin/sh&quot;,</span><br><span class="line">        </span><br><span class="line">        # 运行的脚本</span><br><span class="line">        &quot;Args&quot;: [</span><br><span class="line">            &quot;-c&quot;,</span><br><span class="line">            &quot;while true;do echo shenzai;sleep 1;done&quot;</span><br><span class="line">        ],</span><br><span class="line">        &quot;State&quot;: &#123;</span><br><span class="line">            &quot;Status&quot;: &quot;running&quot;, # 状态，正在运行</span><br><span class="line">            &quot;Running&quot;: true,</span><br><span class="line">            &quot;Paused&quot;: false,</span><br><span class="line">            &quot;Restarting&quot;: false,</span><br><span class="line">            &quot;OOMKilled&quot;: false,</span><br><span class="line">            &quot;Dead&quot;: false,</span><br><span class="line">            &quot;Pid&quot;: 1909, # 父进程id</span><br><span class="line">            &quot;ExitCode&quot;: 0,</span><br><span class="line">            &quot;Error&quot;: &quot;&quot;,</span><br><span class="line">            &quot;StartedAt&quot;: &quot;2020-06-17T12:00:51.093617477Z&quot;,</span><br><span class="line">            &quot;FinishedAt&quot;: &quot;0001-01-01T00:00:00Z&quot;</span><br><span class="line">        &#125;,</span><br><span class="line">        </span><br><span class="line">        # 来源镜像</span><br><span class="line">        &quot;Image&quot;: &quot;sha256:831691599b88ad6cc2a4abbd0e89661a121aff14cfa289ad840fd3946f274f1f&quot;,</span><br><span class="line">        &quot;ResolvConfPath&quot;: &quot;/var/lib/docker/containers/cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388/resolv.conf&quot;,</span><br><span class="line">        &quot;HostnamePath&quot;: &quot;/var/lib/docker/containers/cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388/hostname&quot;,</span><br><span class="line">        &quot;HostsPath&quot;: &quot;/var/lib/docker/containers/cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388/hosts&quot;,</span><br><span class="line">        &quot;LogPath&quot;: &quot;/var/lib/docker/containers/cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388/cb6d7fbc3f27a064137d58282de97b97365dea2705211ebfbad642079cc1b388-json.log&quot;,</span><br><span class="line">        </span><br><span class="line">        </span><br><span class="line">        &quot;Name&quot;: &quot;/dreamy_almeida&quot;,</span><br><span class="line">        &quot;RestartCount&quot;: 0,</span><br><span class="line">        &quot;Driver&quot;: &quot;overlay2&quot;,</span><br><span class="line">        &quot;Platform&quot;: &quot;linux&quot;,</span><br><span class="line">        &quot;MountLabel&quot;: &quot;&quot;,</span><br><span class="line">        &quot;ProcessLabel&quot;: &quot;&quot;,</span><br><span class="line">        &quot;AppArmorProfile&quot;: &quot;&quot;,</span><br><span class="line">        &quot;ExecIDs&quot;: null,</span><br><span class="line">        </span><br><span class="line">        # 主机配置</span><br><span class="line">        &quot;HostConfig&quot;: &#123;</span><br><span class="line">            &quot;Binds&quot;: null,</span><br><span class="line">            &quot;ContainerIDFile&quot;: &quot;&quot;,</span><br><span class="line">            &quot;LogConfig&quot;: &#123;</span><br><span class="line">                &quot;Type&quot;: &quot;json-file&quot;,</span><br><span class="line">                &quot;Config&quot;: &#123;&#125;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;NetworkMode&quot;: &quot;default&quot;,</span><br><span class="line">            &quot;PortBindings&quot;: &#123;&#125;,</span><br><span class="line">            &quot;RestartPolicy&quot;: &#123;</span><br><span class="line">                &quot;Name&quot;: &quot;no&quot;,</span><br><span class="line">                &quot;MaximumRetryCount&quot;: 0</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;AutoRemove&quot;: false,</span><br><span class="line">            &quot;VolumeDriver&quot;: &quot;&quot;,</span><br><span class="line">            &quot;VolumesFrom&quot;: null,</span><br><span class="line">            &quot;CapAdd&quot;: null,</span><br><span class="line">            &quot;CapDrop&quot;: null,</span><br><span class="line">            &quot;Capabilities&quot;: null,</span><br><span class="line">            &quot;Dns&quot;: [],</span><br><span class="line">            &quot;DnsOptions&quot;: [],</span><br><span class="line">            &quot;DnsSearch&quot;: [],</span><br><span class="line">            &quot;ExtraHosts&quot;: null,</span><br><span class="line">            &quot;GroupAdd&quot;: null,</span><br><span class="line">            &quot;IpcMode&quot;: &quot;private&quot;,</span><br><span class="line">            &quot;Cgroup&quot;: &quot;&quot;,</span><br><span class="line">            &quot;Links&quot;: null,</span><br><span class="line">            &quot;OomScoreAdj&quot;: 0,</span><br><span class="line">            &quot;PidMode&quot;: &quot;&quot;,</span><br><span class="line">            &quot;Privileged&quot;: false,</span><br><span class="line">            &quot;PublishAllPorts&quot;: false,</span><br><span class="line">            &quot;ReadonlyRootfs&quot;: false,</span><br><span class="line">            &quot;SecurityOpt&quot;: null,</span><br><span class="line">            &quot;UTSMode&quot;: &quot;&quot;,</span><br><span class="line">            &quot;UsernsMode&quot;: &quot;&quot;,</span><br><span class="line">            &quot;ShmSize&quot;: 67108864,</span><br><span class="line">            &quot;Runtime&quot;: &quot;runc&quot;,</span><br><span class="line">            &quot;ConsoleSize&quot;: [</span><br><span class="line">                0,</span><br><span class="line">                0</span><br><span class="line">            ],</span><br><span class="line">            &quot;Isolation&quot;: &quot;&quot;,</span><br><span class="line">            &quot;CpuShares&quot;: 0,</span><br><span class="line">            &quot;Memory&quot;: 0,</span><br><span class="line">            &quot;NanoCpus&quot;: 0,</span><br><span class="line">            &quot;CgroupParent&quot;: &quot;&quot;,</span><br><span class="line">            &quot;BlkioWeight&quot;: 0,</span><br><span class="line">            &quot;BlkioWeightDevice&quot;: [],</span><br><span class="line">            &quot;BlkioDeviceReadBps&quot;: null,</span><br><span class="line">            &quot;BlkioDeviceWriteBps&quot;: null,</span><br><span class="line">            &quot;BlkioDeviceReadIOps&quot;: null,</span><br><span class="line">            &quot;BlkioDeviceWriteIOps&quot;: null,</span><br><span class="line">            &quot;CpuPeriod&quot;: 0,</span><br><span class="line">            &quot;CpuQuota&quot;: 0,</span><br><span class="line">            &quot;CpuRealtimePeriod&quot;: 0,</span><br><span class="line">            &quot;CpuRealtimeRuntime&quot;: 0,</span><br><span class="line">            &quot;CpusetCpus&quot;: &quot;&quot;,</span><br><span class="line">            &quot;CpusetMems&quot;: &quot;&quot;,</span><br><span class="line">            &quot;Devices&quot;: [],</span><br><span class="line">            &quot;DeviceCgroupRules&quot;: null,</span><br><span class="line">            &quot;DeviceRequests&quot;: null,</span><br><span class="line">            &quot;KernelMemory&quot;: 0,</span><br><span class="line">            &quot;KernelMemoryTCP&quot;: 0,</span><br><span class="line">            &quot;MemoryReservation&quot;: 0,</span><br><span class="line">            &quot;MemorySwap&quot;: 0,</span><br><span class="line">            &quot;MemorySwappiness&quot;: null,</span><br><span class="line">            &quot;OomKillDisable&quot;: false,</span><br><span class="line">            &quot;PidsLimit&quot;: null,</span><br><span class="line">            &quot;Ulimits&quot;: null,</span><br><span class="line">            &quot;CpuCount&quot;: 0,</span><br><span class="line">            &quot;CpuPercent&quot;: 0,</span><br><span class="line">            &quot;IOMaximumIOps&quot;: 0,</span><br><span class="line">            &quot;IOMaximumBandwidth&quot;: 0,</span><br><span class="line">            &quot;MaskedPaths&quot;: [</span><br><span class="line">                &quot;/proc/asound&quot;,</span><br><span class="line">                &quot;/proc/acpi&quot;,</span><br><span class="line">                &quot;/proc/kcore&quot;,</span><br><span class="line">                &quot;/proc/keys&quot;,</span><br><span class="line">                &quot;/proc/latency_stats&quot;,</span><br><span class="line">                &quot;/proc/timer_list&quot;,</span><br><span class="line">                &quot;/proc/timer_stats&quot;,</span><br><span class="line">                &quot;/proc/sched_debug&quot;,</span><br><span class="line">                &quot;/proc/scsi&quot;,</span><br><span class="line">                &quot;/sys/firmware&quot;</span><br><span class="line">            ],</span><br><span class="line">            &quot;ReadonlyPaths&quot;: [</span><br><span class="line">                &quot;/proc/bus&quot;,</span><br><span class="line">                &quot;/proc/fs&quot;,</span><br><span class="line">                &quot;/proc/irq&quot;,</span><br><span class="line">                &quot;/proc/sys&quot;,</span><br><span class="line">                &quot;/proc/sysrq-trigger&quot;</span><br><span class="line">            ]</span><br><span class="line">        &#125;,</span><br><span class="line">        </span><br><span class="line">        # 其他配置</span><br><span class="line">        &quot;GraphDriver&quot;: &#123;</span><br><span class="line">            &quot;Data&quot;: &#123;</span><br><span class="line">                &quot;LowerDir&quot;: &quot;/var/lib/docker/overlay2/3675586ebbd79cd72d2562a90c9380627a331c563724c0dac091f92600af4907-init/diff:/var/lib/docker/overlay2/7f79322e0f58d651a84a555dadd83d92537788172525945d3f538dd95dce336c/diff&quot;,</span><br><span class="line">                &quot;MergedDir&quot;: &quot;/var/lib/docker/overlay2/3675586ebbd79cd72d2562a90c9380627a331c563724c0dac091f92600af4907/merged&quot;,</span><br><span class="line">                &quot;UpperDir&quot;: &quot;/var/lib/docker/overlay2/3675586ebbd79cd72d2562a90c9380627a331c563724c0dac091f92600af4907/diff&quot;,</span><br><span class="line">                &quot;WorkDir&quot;: &quot;/var/lib/docker/overlay2/3675586ebbd79cd72d2562a90c9380627a331c563724c0dac091f92600af4907/work&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;Name&quot;: &quot;overlay2&quot;</span><br><span class="line">        &#125;,</span><br><span class="line">        </span><br><span class="line">        &quot;Mounts&quot;: [], # 挂载</span><br><span class="line">        </span><br><span class="line">        # 基本配置</span><br><span class="line">        &quot;Config&quot;: &#123;</span><br><span class="line">            &quot;Hostname&quot;: &quot;cb6d7fbc3f27&quot;,</span><br><span class="line">            &quot;Domainname&quot;: &quot;&quot;,</span><br><span class="line">            &quot;User&quot;: &quot;&quot;,</span><br><span class="line">            &quot;AttachStdin&quot;: false,</span><br><span class="line">            &quot;AttachStdout&quot;: false,</span><br><span class="line">            &quot;AttachStderr&quot;: false,</span><br><span class="line">            &quot;Tty&quot;: false,</span><br><span class="line">            &quot;OpenStdin&quot;: false,</span><br><span class="line">            &quot;StdinOnce&quot;: false,</span><br><span class="line">            &quot;Env&quot;: [</span><br><span class="line">                &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;</span><br><span class="line">            ], # 基本环境变量，这里没有Java</span><br><span class="line">            </span><br><span class="line">            # 基本命令</span><br><span class="line">            &quot;Cmd&quot;: [</span><br><span class="line">                &quot;/bin/sh&quot;,</span><br><span class="line">                &quot;-c&quot;,</span><br><span class="line">                &quot;while true;do echo shenzai;sleep 1;done&quot;</span><br><span class="line">            ],</span><br><span class="line">            &quot;Image&quot;: &quot;centos&quot;,</span><br><span class="line">            &quot;Volumes&quot;: null,</span><br><span class="line">            &quot;WorkingDir&quot;: &quot;&quot;,</span><br><span class="line">            &quot;Entrypoint&quot;: null,</span><br><span class="line">            &quot;OnBuild&quot;: null,</span><br><span class="line">            &quot;Labels&quot;: &#123;</span><br><span class="line">                &quot;org.label-schema.build-date&quot;: &quot;20200611&quot;,</span><br><span class="line">                &quot;org.label-schema.license&quot;: &quot;GPLv2&quot;,</span><br><span class="line">                &quot;org.label-schema.name&quot;: &quot;CentOS Base Image&quot;,</span><br><span class="line">                &quot;org.label-schema.schema-version&quot;: &quot;1.0&quot;,</span><br><span class="line">                &quot;org.label-schema.vendor&quot;: &quot;CentOS&quot;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;,</span><br><span class="line">        </span><br><span class="line">        # 网卡，比如现在用的是桥接的网卡</span><br><span class="line">        &quot;NetworkSettings&quot;: &#123;</span><br><span class="line">            &quot;Bridge&quot;: &quot;&quot;,</span><br><span class="line">            &quot;SandboxID&quot;: &quot;4d701985d7e77aa153790b697b2f38a61e20555c224b7675e4bf650b82799882&quot;,</span><br><span class="line">            &quot;HairpinMode&quot;: false,</span><br><span class="line">            &quot;LinkLocalIPv6Address&quot;: &quot;&quot;,</span><br><span class="line">            &quot;LinkLocalIPv6PrefixLen&quot;: 0,</span><br><span class="line">            &quot;Ports&quot;: &#123;&#125;,</span><br><span class="line">            &quot;SandboxKey&quot;: &quot;/var/run/docker/netns/4d701985d7e7&quot;,</span><br><span class="line">            &quot;SecondaryIPAddresses&quot;: null,</span><br><span class="line">            &quot;SecondaryIPv6Addresses&quot;: null,</span><br><span class="line">            &quot;EndpointID&quot;: &quot;8a6c71e2bafb19ca7dfd85445ccc4bef6d17467360a243d624089e676a24a018&quot;,</span><br><span class="line">            &quot;Gateway&quot;: &quot;172.17.0.1&quot;,</span><br><span class="line">            &quot;GlobalIPv6Address&quot;: &quot;&quot;,</span><br><span class="line">            &quot;GlobalIPv6PrefixLen&quot;: 0,</span><br><span class="line">            &quot;IPAddress&quot;: &quot;172.17.0.3&quot;,</span><br><span class="line">            &quot;IPPrefixLen&quot;: 16,</span><br><span class="line">            &quot;IPv6Gateway&quot;: &quot;&quot;,</span><br><span class="line">            &quot;MacAddress&quot;: &quot;02:42:ac:11:00:03&quot;,</span><br><span class="line">            &quot;Networks&quot;: &#123;</span><br><span class="line">                &quot;bridge&quot;: &#123;</span><br><span class="line">                    &quot;IPAMConfig&quot;: null,</span><br><span class="line">                    &quot;Links&quot;: null,</span><br><span class="line">                    &quot;Aliases&quot;: null,</span><br><span class="line">                    &quot;NetworkID&quot;: &quot;22b0fd2290ccbc4e066a75d3f01bd8bf32ee4352c5bbcfc9f911287219219571&quot;,</span><br><span class="line">                    &quot;EndpointID&quot;: &quot;8a6c71e2bafb19ca7dfd85445ccc4bef6d17467360a243d624089e676a24a018&quot;,</span><br><span class="line">                    &quot;Gateway&quot;: &quot;172.17.0.1&quot;,</span><br><span class="line">                    &quot;IPAddress&quot;: &quot;172.17.0.3&quot;,</span><br><span class="line">                    &quot;IPPrefixLen&quot;: 16,</span><br><span class="line">                    &quot;IPv6Gateway&quot;: &quot;&quot;,</span><br><span class="line">                    &quot;GlobalIPv6Address&quot;: &quot;&quot;,</span><br><span class="line">                    &quot;GlobalIPv6PrefixLen&quot;: 0,</span><br><span class="line">                    &quot;MacAddress&quot;: &quot;02:42:ac:11:00:03&quot;,</span><br><span class="line">                    &quot;DriverOpts&quot;: null</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">]</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">停止正在疯狂输出的那个容器</span></span><br><span class="line">[root@192 ~]# docker stop cb6d7fbc3f27</span><br><span class="line">cb6d7fbc3f27</span><br></pre></td></tr></table></figure></div>
<h4 id="进入当前正在运行的容器"><a class="markdownIt-Anchor" href="#进入当前正在运行的容器">#</a> 进入当前正在运行的容器</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">我们通常容器都是使用后台方式运行的e</span></span><br><span class="line"></span><br><span class="line">docker exec -it 容器id bashSHELL</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">测试</span></span><br><span class="line">[root@192 ~]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line">c2887d35c71d        centos              &quot;/bin/bash&quot;         35 minutes ago      Up 35 minutes                           vigorous_kare</span><br><span class="line">[root@192 ~]# docker exec -it c2887d35c71d /bin/bash</span><br><span class="line">[root@c2887d35c71d /]# ls</span><br><span class="line">bin  etc   lib	  lost+found  mnt  proc  run   srv  tmp  var</span><br><span class="line">dev  home  lib64  media       opt  root  sbin  sys  usr</span><br><span class="line">[root@c2887d35c71d /]# ps -ef</span><br><span class="line">UID         PID   PPID  C STIME TTY          TIME CMD</span><br><span class="line">root          1      0  0 11:57 pts/0    00:00:00 /bin/bash</span><br><span class="line">root         14      0  0 12:32 pts/1    00:00:00 /bin/bash</span><br><span class="line">root         28     14  0 12:32 pts/1    00:00:00 ps -ef</span><br><span class="line">[root@c2887d35c71d /]# c2887d35c71d</span><br><span class="line">[root@c2887d35c71d /]# exit</span><br><span class="line">exit</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">方式二</span></span><br><span class="line">[root@192 ~]# docker attach c2887d35c71d</span><br><span class="line">[root@c2887d35c71d /]# </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">区别</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">docker <span class="built_in">exec</span> <span class="comment"># 进入容器后开启一个新的终端，可以在里面操作(常用)</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">docker attach 进入容器正在执行的终端，不会启动新的进程</span></span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="从容器内拷贝文件到主机上"><a class="markdownIt-Anchor" href="#从容器内拷贝文件到主机上">#</a> 从容器内拷贝文件到主机上</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">运行</span></span><br><span class="line">[root@192 ~]# docker run -it centos</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">ctrl P Q 不关闭退出，查看</span></span><br><span class="line">[root@0569081aa89c /]# [root@192 ~]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line">0569081aa89c        centos              &quot;/bin/bash&quot;         19 seconds ago      Up 19 seconds    </span><br><span class="line">hopeful_chebyshev</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看主机home下无文件</span></span><br><span class="line">[root@192 ~]# cd /home</span><br><span class="line">[root@192 home]# ls</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入正在运行的容器</span></span><br><span class="line">[root@192 home]# docker attach 0569081aa89c</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入容器home目录</span></span><br><span class="line">[root@0569081aa89c /]# cd /home</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">在目录中创建java文件</span></span><br><span class="line">[root@0569081aa89c home]# touch test.java</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">退出并停止容器</span></span><br><span class="line">[root@0569081aa89c home]# exit</span><br><span class="line">exit</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看现在运行的容器</span></span><br><span class="line">[root@192 home]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">容器虽然被停止，但是数据都会保留</span></span><br><span class="line">[root@192 home]# docker ps -a</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS               NAMES</span><br><span class="line">0569081aa89c        centos              &quot;/bin/bash&quot;              3 minutes ago       Exited (0) 8 seconds ago                           hopeful_chebyshev</span><br><span class="line">f589e5684a01        centos              &quot;/bin/bash&quot;              44 minutes ago      Exited (0) 44 minutes ago                          cranky_easley</span><br><span class="line">cb6d7fbc3f27        centos              &quot;/bin/sh -c &#x27;while t…&quot;   54 minutes ago      Exited (137) 42 minutes ago                        dreamy_almeida</span><br><span class="line">c2887d35c71d        centos              &quot;/bin/bash&quot;              58 minutes ago      Exited (127) 16 minutes ago                        vigorous_kare</span><br><span class="line">8ce188e5fee3        centos              &quot;/bin/bash&quot;              About an hour ago   Exited (0) About an hour ago                       tender_dirac</span><br><span class="line">7b1a7dd10ea4        centos              &quot;/bin/bash&quot;              9 hours ago         Exited (0) 9 hours ago                             fervent_mirzakhani</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">容器数据拷贝到主机</span></span><br><span class="line">[root@192 home]# docker cp 0569081aa89c:/home/test.java /home</span><br><span class="line">[root@192 home]# ls</span><br><span class="line">test.java</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">拷贝是一个手动过程，未来我们使用 -v 卷的技术，可以实现自动同步 /home /home</span></span><br></pre></td></tr></table></figure></div>
<h4 id="查看内容占用"><a class="markdownIt-Anchor" href="#查看内容占用">#</a> 查看内容占用</h4>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker stats</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<h4 id="小结"><a class="markdownIt-Anchor" href="#小结">#</a> 小结</h4>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617210554147.png"
                      alt="image-20200617210554147"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></td><td class="code"><pre><span class="line">[root@192 home]# docker --help</span><br><span class="line"></span><br><span class="line">Usage:	docker [OPTIONS] COMMAND</span><br><span class="line"></span><br><span class="line">A self-sufficient runtime for containers</span><br><span class="line"></span><br><span class="line">Options:</span><br><span class="line">      --config string      Location of client config</span><br><span class="line">                           files (default &quot;/root/.docker&quot;)</span><br><span class="line">  -c, --context string     Name of the context to use to</span><br><span class="line">                           connect to the daemon</span><br><span class="line">                           (overrides DOCKER_HOST env var</span><br><span class="line">                           and default context set with</span><br><span class="line">                           &quot;docker context use&quot;)</span><br><span class="line">  -D, --debug              Enable debug mode</span><br><span class="line">  -H, --host list          Daemon socket(s) to connect to</span><br><span class="line">  -l, --log-level string   Set the logging level</span><br><span class="line">                           (&quot;debug&quot;|&quot;info&quot;|&quot;warn&quot;|&quot;error&quot;|&quot;fatal&quot;) (default &quot;info&quot;)</span><br><span class="line">      --tls                Use TLS; implied by --tlsverify</span><br><span class="line">      --tlscacert string   Trust certs signed only by</span><br><span class="line">                           this CA (default</span><br><span class="line">                           &quot;/root/.docker/ca.pem&quot;)</span><br><span class="line">      --tlscert string     Path to TLS certificate file</span><br><span class="line">                           (default &quot;/root/.docker/cert.pem&quot;)</span><br><span class="line">      --tlskey string      Path to TLS key file (default</span><br><span class="line">                           &quot;/root/.docker/key.pem&quot;)</span><br><span class="line">      --tlsverify          Use TLS and verify the remote</span><br><span class="line">  -v, --version            Print version information and quit</span><br><span class="line"></span><br><span class="line">Management Commands:</span><br><span class="line">  builder     Manage builds</span><br><span class="line">  config      Manage Docker configs</span><br><span class="line">  container   Manage containers</span><br><span class="line">  context     Manage contexts</span><br><span class="line">  engine      Manage the docker engine</span><br><span class="line">  image       Manage images</span><br><span class="line">  network     Manage networks</span><br><span class="line">  node        Manage Swarm nodes</span><br><span class="line">  plugin      Manage plugins</span><br><span class="line">  secret      Manage Docker secrets</span><br><span class="line">  service     Manage services</span><br><span class="line">  stack       Manage Docker stacks</span><br><span class="line">  swarm       Manage Swarm</span><br><span class="line">  system      Manage Docker</span><br><span class="line">  trust       Manage trust on Docker images</span><br><span class="line">  volume      Manage volumes</span><br><span class="line"></span><br><span class="line">Commands:</span><br><span class="line">  attach      Attach local standard input, output, and error streams to a running container</span><br><span class="line">  build       Build an image from a Dockerfile</span><br><span class="line">  commit      Create a new image from a container&#x27;s changes</span><br><span class="line">  cp          Copy files/folders between a container and the local filesystem</span><br><span class="line">  create      Create a new container</span><br><span class="line">  diff        Inspect changes to files or directories on a container&#x27;s filesystem</span><br><span class="line">  events      Get real time events from the server</span><br><span class="line">  exec        Run a command in a running container</span><br><span class="line">  export      Export a container&#x27;s filesystem as a tar archive</span><br><span class="line">  history     Show the history of an image</span><br><span class="line">  images      List images</span><br><span class="line">  import      Import the contents from a tarball to create a filesystem image</span><br><span class="line">  info        Display system-wide information</span><br><span class="line">  inspect     Return low-level information on Docker objects</span><br><span class="line">  kill        Kill one or more running containers</span><br><span class="line">  load        Load an image from a tar archive or STDIN</span><br><span class="line">  login       Log in to a Docker registry</span><br><span class="line">  logout      Log out from a Docker registry</span><br><span class="line">  logs        Fetch the logs of a container</span><br><span class="line">  pause       Pause all processes within one or more containers</span><br><span class="line">  port        List port mappings or a specific mapping for the container</span><br><span class="line">  ps          List containers</span><br><span class="line">  pull        Pull an image or a repository from a registry</span><br><span class="line">  push        Push an image or a repository to a registry</span><br><span class="line">  rename      Rename a container</span><br><span class="line">  restart     Restart one or more containers</span><br><span class="line">  rm          Remove one or more containers</span><br><span class="line">  rmi         Remove one or more images</span><br><span class="line">  run         Run a command in a new container</span><br><span class="line">  save        Save one or more images to a tar archive (streamed to STDOUT by default)</span><br><span class="line">  search      Search the Docker Hub for images</span><br><span class="line">  start       Start one or more stopped containers</span><br><span class="line">  stats       Display a live stream of container(s) resource usage statistics</span><br><span class="line">  stop        Stop one or more running containers</span><br><span class="line">  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE</span><br><span class="line">  top         Display the running processes of a container</span><br><span class="line">  unpause     Unpause all processes within one or more containers</span><br><span class="line">  update      Update configuration of one or more containers</span><br><span class="line">  version     Show the Docker version information</span><br><span class="line">  wait        Block until one or more containers stop, then print their exit codes</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/img/202306051637646.png"
                      alt="image-20200617210932306"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/img/202306051637636.png"
                      alt="image-20200617211021003"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/img/202306051637671.png"
                      alt="image-20200617211039508"
                ></p>
<h4 id="作业练习"><a class="markdownIt-Anchor" href="#作业练习">#</a> 作业练习</h4>
<h5 id="部署nginx"><a class="markdownIt-Anchor" href="#部署nginx">#</a> 部署 Nginx</h5>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618100621199.png"
                      alt="image-20200618100621199"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">官网搜索nginx，可以看到帮助文档</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下载镜像</span></span><br><span class="line">[root@192 home]# docker pull nginx</span><br><span class="line">Using default tag: latest</span><br><span class="line">latest: Pulling from library/nginx</span><br><span class="line">8559a31e96f4: Pull complete </span><br><span class="line">8d69e59170f7: Pull complete </span><br><span class="line">3f9f1ec1d262: Pull complete </span><br><span class="line">d1f5ff4f210d: Pull complete </span><br><span class="line">1e22bfa8652e: Pull complete </span><br><span class="line">Digest: sha256:21f32f6c08406306d822a0e6e8b7dc81f53f336570e852e25fbe1e3e3d0d0133</span><br><span class="line">Status: Downloaded newer image for nginx:latest</span><br><span class="line">docker.io/library/nginx:latest</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看镜像</span></span><br><span class="line">[root@192 home]# docker images</span><br><span class="line">REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE</span><br><span class="line">centos              latest              831691599b88        13 hours ago        215MB</span><br><span class="line">nginx               latest              2622e6cca7eb        7 days ago          132MB</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">运行测试</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-d 后台运行，--name 命名，-p 暴露端口，3344服务器、宿主机的端口，容器内部端口</span></span><br><span class="line">[root@192 home]# docker run -d --name nginx01 -p:3344:80 nginx</span><br><span class="line">38dbf7bdcaef232d269b7184d91e44e06087181b5ee929494e177ad526810fa8</span><br><span class="line">[root@192 home]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES</span><br><span class="line">38dbf7bdcaef        nginx               &quot;/docker-entrypoint.…&quot;   7 seconds ago       Up 6 seconds        0.0.0.0:3344-&gt;80/tcp   nginx01</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">使用3344可以访问成功</span></span><br><span class="line">[root@192 home]# curl localhost:3344</span><br><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">&lt;head&gt;</span><br><span class="line">&lt;title&gt;Welcome to nginx!&lt;/title&gt;</span><br><span class="line">&lt;style&gt;</span><br><span class="line">    body &#123;</span><br><span class="line">        width: 35em;</span><br><span class="line">        margin: 0 auto;</span><br><span class="line">        font-family: Tahoma, Verdana, Arial, sans-serif;</span><br><span class="line">    &#125;</span><br><span class="line">&lt;/style&gt;</span><br><span class="line">&lt;/head&gt;</span><br><span class="line">&lt;body&gt;</span><br><span class="line">&lt;h1&gt;Welcome to nginx!&lt;/h1&gt;</span><br><span class="line">&lt;p&gt;If you see this page, the nginx web server is successfully installed and</span><br><span class="line">working. Further configuration is required.&lt;/p&gt;</span><br><span class="line"></span><br><span class="line">&lt;p&gt;For online documentation and support please refer to</span><br><span class="line">&lt;a href=&quot;http://nginx.org/&quot;&gt;nginx.org&lt;/a&gt;.&lt;br/&gt;</span><br><span class="line">Commercial support is available at</span><br><span class="line">&lt;a href=&quot;http://nginx.com/&quot;&gt;nginx.com&lt;/a&gt;.&lt;/p&gt;</span><br><span class="line"></span><br><span class="line">&lt;p&gt;&lt;em&gt;Thank you for using nginx.&lt;/em&gt;&lt;/p&gt;</span><br><span class="line">&lt;/body&gt;</span><br><span class="line">&lt;/html&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p>端口暴露</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/img/202306051637674.png"
                      alt="image-20200617212310709"
                ></p>
<p>可以公网访问</p>
<p>找到服务器地址</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617213213721.png"
                      alt="image-20200617213213721"
                ></p>
<p>浏览器输入 192.168.147.132:3344/</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200617213142079.png"
                      alt="image-20200617213142079"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">[root@192 home]# docker ps</span><br><span class="line">CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES</span><br><span class="line">38dbf7bdcaef        nginx               &quot;/docker-entrypoint.…&quot;   21 minutes ago      Up 21 minutes       0.0.0.0:3344-&gt;80/tcp   nginx01</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入容器</span></span><br><span class="line">[root@192 home]# docker exec -it nginx01 /bin/bash</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查一下nginx在哪</span></span><br><span class="line">root@38dbf7bdcaef:/# whereis nginx</span><br><span class="line">nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">到这个目录</span></span><br><span class="line">root@38dbf7bdcaef:/# cd /etc/nginx</span><br><span class="line">root@38dbf7bdcaef:/etc/nginx# ls</span><br><span class="line">conf.d		koi-utf  mime.types  nginx.conf   uwsgi_params</span><br><span class="line">fastcgi_params	koi-win  modules     scgi_params  win-utf</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">退出</span></span><br><span class="line">root@38dbf7bdcaef:/etc/nginx# exit</span><br><span class="line">exit</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">停止</span></span><br><span class="line">[root@192 home]# docker stop 38dbf7bdcaef</span><br><span class="line">38dbf7bdcaef</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p>再次刷新网页，服务关闭</p>
<p>思考问题：每次改动 nginx 配置文件，都需要进入容器内部，十分麻烦，要是可以在容器外部提供一个映射路径，达到在容器修改文件名，容器内部就可以自动修改？-v 数据卷技术！</p>
<h5 id="部署tomcat"><a class="markdownIt-Anchor" href="#部署tomcat">#</a> 部署 tomcat</h5>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618100551587.png"
                      alt="image-20200618100551587"
                ></p>
<p>在 docker hub 上查看版本号和使用方法</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618100319796.png"
                      alt="image-20200618100319796"
                ></p>
<p>官方文档一定要翻烂，超多版本，我的天呐～</p>
<h6 id="官方方法"><a class="markdownIt-Anchor" href="#官方方法">#</a> 官方方法</h6>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">docker run -it --rm tomcat:9.0</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">docker run 可以不用pull，能自动下载</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-it 直接进去运行</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">--<span class="built_in">rm</span> 是什么意思？入门的意思？</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">我们之前的启动都是后台，停止了容器之后，容器还是可以查到</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">写了--<span class="built_in">rm</span>，类似阅后即焚模式，用完即删除，这种通常用来测试</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">最后冒号查好的版本号</span></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618101811914.png"
                      alt="image-20200618101811914"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618101849917.png"
                      alt="image-20200618101849917"
                ></p>
<p>ctrl+c 退出</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker ps -a</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618102022167.png"
                      alt="image-20200618102022167"
                ></p>
<p>可以看到并没有 tomcat，印证阅后即焚模式，容器会删除，镜像不会删除</p>
<p>平时不建议这样搞</p>
<h6 id="正常方法"><a class="markdownIt-Anchor" href="#正常方法">#</a> 正常方法</h6>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull tomcat:9.0 # 之前下过了，应该不用下了，这里老师讲错了</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618102544564.png"
                      alt="image-20200618102544564"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动运行，应该加上版本号</span></span><br><span class="line">docker run -d -p 3355:8080 --name tomcat01 tomcat</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618102837397.png"
                      alt="image-20200618102837397"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入容器</span></span><br><span class="line">docker exec -it tomcat01 /bin/bash</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618103109004.png"
                      alt="image-20200618103109004"
                ></p>
<p>发现问题</p>
<ol>
<li>linux 命令少了</li>
<li>没有 webapps</li>
</ol>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618103407205.png"
                      alt="image-20200618103407205"
                ></p>
<p>这是阿里云镜像的原因：默认使用最小镜像，所有不必要的都剔除了，保证最小可运行环境</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618103848104.png"
                      alt="image-20200618103848104"
                ></p>
<p>再次找到结构</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618104052242.png"
                      alt="image-20200618104052242"
                ></p>
<p>在浏览器中输入：<a class="link"   target="_blank" rel="noopener" href="http://192.168.147.132:3355/" >http://192.168.147.132:3355/ <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618103958168.png"
                      alt="image-20200618103958168"
                ></p>
<p>思考问题：我们以后部署项目，如果每次都要进入容器是不是身份麻烦？我要是可以在容器外部提供一个映射路径，webapps，我们在外部放置项目，就自动同步到内部就好了！</p>
<p>docker 容器 tomcat + 网站</p>
<p>docker mysql</p>
<h5 id="部署eskibana"><a class="markdownIt-Anchor" href="#部署eskibana">#</a> 部署 es+kibana</h5>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618104950722.png"
                      alt="image-20200618104950722"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">es 暴露的端口很多</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">es 十分耗内存</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">es 的数据一般需要放置到安全目录！挂载</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动 elasticsearch</span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">docker run -d --name elasticsearch01 -p 9200:9200 -p 9300:9300 -e <span class="string">&quot;discovery.type=single-node&quot;</span> elasticsearch:7.6.2</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看内存占用情况</span></span><br><span class="line">docker stats</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618111713885.png"
                      alt="image-20200618111713885"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">先感觉stop一下</span></span><br><span class="line">docker stop ba18713ca536</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618105057785.png"
                      alt="image-20200618105057785"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">通过 -e 限制内存</span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">docker run -d --name elasticsearch02 -p 9200:9200 -p 9300:9300 -e <span class="string">&quot;discovery.type=single-node&quot;</span> -e ES_JAVA_OPTS=“-Xms64m -Xmx512m” elasticsearch:7.6.2</span></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618113018622.png"
                      alt="image-20200618113018622"
                ></p>
<p>没成功啊，SEI 能告诉我为啥！！</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d --name elasticsearch02 -p 9200:9200 -p 9300:9300 -e &quot;discovery.type=single-node&quot; -e ES_JAVA_OPTS=&quot;-Xms64m -Xmx512m&quot; elasticsearch:7.6.2</span><br></pre></td></tr></table></figure></div>
<blockquote>
<p>py0003null 大佬:<br>
“ES_JAVA_OPTS=-Xms64m -Xmx512m”</p>
<p>py0003null 大佬:<br>
 引号提前试试</p>
</blockquote>
<p>原因是引号！！你没觉得怪怪的嘛</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618115302656.png"
                      alt="image-20200618115302656"
                ></p>
<p>此时查看 stats，发现内存占用在控制范围内</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618115149971.png"
                      alt="image-20200618115149971"
                ></p>
<p>ctrl + C 退出，记得 stop</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618115921069.png"
                      alt="image-20200618115921069"
                ></p>
<h5 id="思考用kibana链接elasticsearch"><a class="markdownIt-Anchor" href="#思考用kibana链接elasticsearch">#</a> 思考：用 kibana 链接 elasticsearch</h5>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618113556445.png"
                      alt="image-20200618113556445"
                ></p>
<h3 id="可视化"><a class="markdownIt-Anchor" href="#可视化">#</a> 可视化</h3>
<ul>
<li>portainer (先用这个)</li>
<li>Rancher (CI/CD 时用)</li>
</ul>
<h4 id="portainer"><a class="markdownIt-Anchor" href="#portainer">#</a> portainer</h4>
<p>Docker 图像化界面管理工具，提供一个后台面板供我们操作！</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d -p 8088:9000 --restart=always -v /var/run/docker.sock:/var/run/docker --privileged=true portainer/portainer</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618114542622.png"
                      alt="image-20200618114542622"
                ></p>
<p>访问外网 8088</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618114902169.png"
                      alt="image-20200618114902169"
                ></p>
<p>用户名</p>
<p>密码</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618134706491.png"
                      alt="image-20200618134706491"
                ></p>
<p>【中午吃饭重连了一下，失败，不知道发生了啥】</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618135424706.png"
                      alt="image-20200618135424706"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618135450037.png"
                      alt="image-20200618135450037"
                ></p>
<p>【平时不会用这个，好吧，先往下】</p>
<h3 id=""><a class="markdownIt-Anchor" href="#">#</a> </h3>
<h2 id="docker镜像"><a class="markdownIt-Anchor" href="#docker镜像">#</a> Docker 镜像</h2>
<h3 id="原理"><a class="markdownIt-Anchor" href="#原理">#</a> 原理</h3>
<p>UnionFS 联合文件系统</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618140242423.png"
                      alt="image-20200618140242423"
                ></p>
<p>bootfs：boot file system</p>
<p>rootfs：root file system</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618140907894.png"
                      alt="image-20200618140907894"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618140932621.png"
                      alt="image-20200618140932621"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618141014511.png"
                      alt="image-20200618141014511"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618153329894.png"
                      alt="image-20200618153329894"
                ></p>
<p>Docker 镜像都是只读的，当容器启动时，一个新的可写层被加到镜像的顶部，这一层就是我们通常说的容器层，容器层之下的都叫镜像层</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618153855605.png"
                      alt="image-20200618153855605"
                ></p>
<h3 id="commit提交镜像"><a class="markdownIt-Anchor" href="#commit提交镜像">#</a> commit 提交镜像</h3>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker commit # 提交容器成为一个新的副本</span><br><span class="line">docker commit -m=&quot;提交的描述信息&quot; -a=&quot;作者&quot; 容器id 目标镜像名：[TAG]</span><br></pre></td></tr></table></figure></div>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br><span class="line">docker run -it -p 8080:8080 tomcat</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618154457286.png"
                      alt="image-20200618154457286"
                ></p>
<p>这是一个前台程序</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618154736475.png"
                      alt="image-20200618154736475"
                ></p>
<p>将 webapps.dist 里面所有的文件拷贝到 webapps 里面，其中 - r 必须有，表示目录递归拷贝</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618154943194.png"
                      alt="image-20200618154943194"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618155750591.png"
                      alt="image-20200618155750591"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker commit -a=&quot;paidaxing&quot; -m=&quot;add webapps app&quot; 当前容器的id tomcat02:1.0</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618160425265.png"
                      alt="image-20200618160425265"
                ></p>
<p>发现新的版本，比之前的大了一些，因为里面记录了我们的改动</p>
<blockquote>
<p>如果想保存当前容器的状态，可以通过 commit 提交，获得一个镜像</p>
<p>好比我们以前学习 VM 的时候的快照</p>
<p>到这里算是入门了</p>
<p>接下来三个部分是 docker 的精髓</p>
</blockquote>
<h2 id="容器数据卷"><a class="markdownIt-Anchor" href="#容器数据卷">#</a> 容器数据卷</h2>
<h3 id="什么是容器卷"><a class="markdownIt-Anchor" href="#什么是容器卷">#</a> 什么是容器卷</h3>
<p>docker 是要将应用和环境打包成一个镜像</p>
<p>这样，数据就不应该在容器中，否则容器删除，数据就会丢失，这就是删库跑路</p>
<p>故容器之间要有一个数据共享技术</p>
<p>在 Docker 容器中产生的数据，同步到本地，这就是卷技术</p>
<p>本质上是一个目录挂载，将容器内的目录挂载到虚拟机上</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618162917672.png"
                      alt="image-20200618162917672"
                ></p>
<p>目的：容器的持久化和同步操作</p>
<p>容器间可以数据共享</p>
<h3 id="使用数据卷"><a class="markdownIt-Anchor" href="#使用数据卷">#</a> 使用数据卷</h3>
<p>方式一：直接使用命令来挂载</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker run -it -v -p</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-it 交互式进入</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-v volume卷技术</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">-p 主机端口</span></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618163659503.png"
                      alt="image-20200618163659503"
                ></p>
<p>新开一个窗口</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker inspect 容器id</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618163938466.png"
                      alt="image-20200618163938466"
                ></p>
<p>找到挂载信息 Mounts</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618164148642.png"
                      alt="image-20200618164148642"
                ></p>
<p>测试</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618164818624.png"
                      alt="image-20200618164818624"
                ></p>
<p>容器停止后，修改主机文件，再启动容器的时候，数据同样改变</p>
<p>双向同步</p>
<h3 id="实战安装mysql"><a class="markdownIt-Anchor" href="#实战安装mysql">#</a> 实战安装 mysql</h3>
<p>MySQL 的数据持久化命令</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">docker search mysql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">拉取</span></span><br><span class="line">docker pull mysql:5.7</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">挂载</span></span><br><span class="line">docker run -d -p 3310:3306 -v /home/mysql/conf:/etc/mysql/conf.d -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 --name mysql01 mysql5.7</span><br><span class="line"></span><br><span class="line">-d 后台运行</span><br><span class="line">-p 端口映射</span><br><span class="line">-v 卷挂载</span><br><span class="line">-e 环境配置 安装启动mysql需要配置密码</span><br><span class="line">--name 容器名字</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618171353336.png"
                      alt="image-20200618171353336"
                ></p>
<p>链接测试：打开 SQLyog</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618173234347.png"
                      alt="image-20200618173234347"
                ></p>
<p>点 测试链接</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618173300551.png"
                      alt="image-20200618173300551"
                ></p>
<p>点 链接</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618173729692.png"
                      alt="image-20200618173729692"
                ></p>
<h3 id="具名和匿名挂载"><a class="markdownIt-Anchor" href="#具名和匿名挂载">#</a> 具名和匿名挂载</h3>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618203452205.png"
                      alt="image-20200618203452205"
                ></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/img/202306051637679.png"
                      alt="image-20200618203744983"
                ></p>
<h3 id="-2"><a class="markdownIt-Anchor" href="#-2">#</a> </h3>
<p>DockerFile 使用来构建 docker 镜像的文件</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618211547398.png"
                      alt="image-20200618211547398"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install vim # 编辑文件的，没有装一下</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618211516566.png"
                      alt="image-20200618211516566"
                ></p>
<p>安装完之后就可以运行这个命令了</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618211803012.png"
                      alt="image-20200618211803012"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">镜像是一层一层的，脚本是一行一行的</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">指令都是大写的</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">这里的每个命令可以理解为镜像的一层</span></span><br><span class="line"></span><br><span class="line">FROM centos</span><br><span class="line"></span><br><span class="line">VOLUME [&quot;volume01&quot;,&quot;volume02&quot;] # 再创建镜像的时候就挂载出来</span><br><span class="line"></span><br><span class="line">CMD echo &quot;---end---&quot;</span><br><span class="line">CMD /bin/bash</span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618211023834.png"
                      alt="image-20200618211023834"
                ></p>
<p>想保存并退出</p>
<blockquote>
<p>Wesley.:<br>
shift  加  冒号</p>
</blockquote>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618211318410.png"
                      alt="image-20200618211318410"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cat dockerfile1</span><br><span class="line"></span><br><span class="line">docker build -f dockerfile1 -t padaxing/centos:1.0 .  # 最后的点很重要 镜像名不能有/</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618212936481.png"
                      alt="image-20200618212936481"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618213310752.png"
                      alt="image-20200618213310752"
                ></p>
<p>启动生成的镜像</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618220658979.png"
                      alt="image-20200618220658979"
                ></p>
<p>在容器内部创建一个文件</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618221801103.png"
                      alt="image-20200618221801103"
                ></p>
<p>查看 Mounts，Source 对应容器外目录，匿名挂载卷</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618221837895.png"
                      alt="image-20200618221837895"
                ></p>
<p>测试一下，在 container volume01 下生成文件</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200618222224352.png"
                      alt="image-20200618222224352"
                ></p>
<p>在主机挂载路径下，也同样生成</p>
<h3 id="多个容器数据共享"><a class="markdownIt-Anchor" href="#多个容器数据共享">#</a> 多个容器数据共享</h3>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621165403842.png"
                      alt="image-20200621165403842"
                ></p>
<p>看一下有啥 images</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621165733780.png"
                      alt="image-20200621165733780"
                ></p>
<p>启动 docker01，用之前建的 padaxing/centos 1.0  镜像</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -it --name docker01 padaxing/centos:1.0 # 1.0必须写</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621170429658.png"
                      alt="image-20200621170429658"
                ></p>
<p>当前这个 ctrl+p+q 不停止退出</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621170540593.png"
                      alt="image-20200621170540593"
                ></p>
<p>依次启动 docker02、docker03</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -it --name docker02 --volumes-from docker01 padaxing/centos:1.0</span><br></pre></td></tr></table></figure></div>
<p>docker02 继承 docker01 的 volumes</p>
<p>可以验证，在 docker01 下加一个数据，在 docker02 下也会出现</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621171513650.png"
                      alt="image-20200621171513650"
                ></p>
<p>创建 docker03，同样继承 docker01</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -it --name docker03 --volumes-from docker01 padaxing/centos:1.0</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621172333639.png"
                      alt="image-20200621172333639"
                ></p>
<p>在 docker03 的 volume01 下建立文件，在 docker01 的 volume01 下同样也有</p>
<p>即通过–volumes-from 可以实现不同容器间的数据共享</p>
<p>删除 docker01，数据还在</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rm -f </span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621172830779.png"
                      alt="image-20200621172830779"
                ></p>
<p>可以看到，删除 docker01，进入 docker02，数据依然在</p>
<p>结论：</p>
<p>容器之间配置信息的传递，数据卷容器的生命周期一直持续到没有容器使用位置</p>
<p>但是如果持久化到了本地，即使所有容器删除了，本地数据是不会删除的</p>
<hr>
<h2 id="dockerfile"><a class="markdownIt-Anchor" href="#dockerfile">#</a> DockerFile</h2>
<p>是用来构建 docker 镜像的文件，可以理解为命令参数脚本</p>
<p>构建步骤：</p>
<ol>
<li>编写一个 dockerfile 文件</li>
<li>docker build 构建成为一个镜像</li>
<li>docker run 运行镜像</li>
<li>docker push 发布镜像（DockerHub、阿里云镜像仓库 私有 / 共有）</li>
</ol>
<p>这个写一个项目时一样的</p>
<h3 id="官方dockerfile示例"><a class="markdownIt-Anchor" href="#官方dockerfile示例">#</a> 官方 DockerFile 示例</h3>
<p>看一下官方的 DockerFile</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621174204807.png"
                      alt="image-20200621174204807"
                ></p>
<p>可以看到官方镜像都是基础包，很多功能没有，我们通常会自己搭建自己的镜像</p>
<p>官方既然可以制作镜像，我们亦可以</p>
<hr>
<h3 id="dockerfile基础知识"><a class="markdownIt-Anchor" href="#dockerfile基础知识">#</a> DockerFile 基础知识</h3>
<ol>
<li>每个指令都必须是大写字母</li>
<li>按照从上到下顺序执行</li>
<li>*#* 表示注释</li>
<li>每一个指令都会创建体检一个新的镜像层，并提交</li>
</ol>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621174948310.png"
                      alt="image-20200621174948310"
                ></p>
<p>docker 是面向开发的，我们以后要发布项目，做镜像，就要编写 dockerfile 文件，这个文件十分简单！</p>
<p>Docker 镜像逐渐成为企业的交付标准，必须掌握！</p>
<hr>
<h3 id="dockerfile命令"><a class="markdownIt-Anchor" href="#dockerfile命令">#</a> DockerFile 命令</h3>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/171.jpg"
                      alt="æ¥çæºå¾å"
                ></p>
<h3 id="-3"><a class="markdownIt-Anchor" href="#-3">#</a> </h3>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">FROM # 基础镜像 比如centos</span><br><span class="line">MAINTAINER # 镜像是谁写的 姓名+邮箱</span><br><span class="line">RUN # 镜像构建时需要运行的命令</span><br><span class="line">ADD # 添加，比如添加一个tomcat压缩包</span><br><span class="line">WORKDIR # 镜像的工作目录</span><br><span class="line">VOLUME # 挂载的目录</span><br><span class="line">EXPOSE # 指定暴露端口，跟-p一个道理</span><br><span class="line">RUN # 最终要运行的</span><br><span class="line">CMD # 指定这个容器启动的时候要运行的命令，只有最后一个会生效，而且可被替代</span><br><span class="line">ENTRYPOINT # 指定这个容器启动的时候要运行的命令，可以追加命令</span><br><span class="line">ONBUILD # 当构建一个被继承Dockerfile 这个时候运行ONBUILD指定，触发指令</span><br><span class="line">COPY # 将文件拷贝到镜像中</span><br><span class="line">ENV # 构建的时候设置环境变量</span><br></pre></td></tr></table></figure></div>
<h3 id="实战构建自己的centos"><a class="markdownIt-Anchor" href="#实战构建自己的centos">#</a> 实战构建自己的 centos</h3>
<p>Docker Hub 中 99% 的镜像都是从 FROM scratch 开始的</p>
<p>添加 centos7 的压缩包</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">创建一个自己的centos</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入home目录</span></span><br><span class="line">cd /home</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">创建一个目录，之后的东西都保存到这里</span></span><br><span class="line">mkdir dockerfile</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入这个目录</span></span><br><span class="line">cd dockerfile/</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">创建一个dockerfile，名字叫mydockerfile</span></span><br><span class="line">vim mydockerfile-centos</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure></div>
<p>xshell 新开一个界面</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">官方默认centos</span></span><br><span class="line">docker run -it centos</span><br><span class="line">pwd # 官方默认有pwd命令</span><br><span class="line">vim # 官方默认没有vim命令</span><br><span class="line">ifconfig # 官方默认没有ifconfig命令</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621184333206.png"
                      alt="image-20200621184333206"
                ></p>
<p>回到 mydockerfile</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621184847524.png"
                      alt="image-20200621184847524"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">下面给官方centos加上自定义的内容</span></span><br><span class="line">FROM centos</span><br><span class="line">MAINTAINER padaxing&lt;010301200@hai.com&gt;</span><br><span class="line"></span><br><span class="line">ENV MYPATH /usr/local</span><br><span class="line">WORKDIR $MYPATH</span><br><span class="line"></span><br><span class="line">RUN yum -y install vim</span><br><span class="line">RUN yum -y install net-tools</span><br><span class="line"></span><br><span class="line">EXPOSE 80</span><br><span class="line"></span><br><span class="line">CMD echo $MYPATH</span><br><span class="line">CMD echo &quot;---end---&quot;</span><br><span class="line">CMD /bin/bash</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621185539523.png"
                      alt="image-20200621185539523"
                ></p>
<p>ESC, shif + : 输入 wq 保存并退出</p>
<p>如果写错了需要修改、</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">vim mydockerfile-centos</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入之后按i或者INSERT键即可修改</span></span><br></pre></td></tr></table></figure></div>
<p>下面通过这个这个文件创建镜像</p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker build -f dockerfile-centos -t mycentos:0.1 .</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621190219978.png"
                      alt="image-20200621190219978"
                ></p>
<p>依次执行命令</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621190439448.png"
                      alt="image-20200621190439448"
                ></p>
<p>最终返回 Successfully 表示成功</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621190524848.png"
                      alt="image-20200621190524848"
                ></p>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker run -it mycentos:0.1 # 版本号必须写，不然他会去找最新的</span><br><span class="line">pwd</span><br><span class="line">vim</span><br><span class="line">ifconfig</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621190812481.png"
                      alt="image-20200621190812481"
                ></p>
<p>这时可以看到这些功能都有了</p>
<p>可以通过查看 docker 构建历史</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200621192103460.png"
                      alt="image-20200621192103460"
                ></p>
<p>可以看到当前这个镜像是怎么一步一步构建起来的</p>
<p>我们平时拿到一个镜像也可以通过这个方法研究一下他是怎么做的</p>
<h3 id="cmd与entrypoint"><a class="markdownIt-Anchor" href="#cmd与entrypoint">#</a> CMD 与 ENTRYPOINT</h3>
<div class="highlight-container" data-rel="Shell"><figure class="iseeu highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">FROM centos</span><br><span class="line">CMD [&quot;ls&quot;,&quot;-a&quot;] # 启动centos展示目录</span><br></pre></td></tr></table></figure></div>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/img/202306051637698.png"
                      alt="image-20200622075427103"
                ></p>
<p>测试 ENTRYPOINT</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="../../../../%E7%AC%94%E8%AE%B0/Docker.assets/image-20200622075653789.png"
                      alt="image-20200622075653789"
                ></p>
<p>run 的时候可以直接加命令</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="http://tuchuang.wenhe9.cn/image-20200622075802180.png"
                      alt="image-20200622075802180"
                ></p>
<p>Docker 中许多命令都十分相似，我们需要了解他们的区别，最好的方式就是这样对比测试</p>

            </div>

            
                <div class="post-copyright-info">
                    <div class="article-copyright-info-container">
    <ul>
        <li><strong>标题:</strong> Docker</li>
        <li><strong>作者:</strong> meteor</li>
        <li><strong>创建于:</strong> 2023-06-05 16:37:06</li>
        
            <li>
                <strong>更新于:</strong> 2023-06-05 00:38:03
            </li>
        
        <li>
            <strong>链接:</strong> https://gitee.com/du-jinliang/2023/06/06/Docker/
        </li>
        <li>
            <strong>版权声明:</strong> 本文章采用 <a class="license" target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0</a> 进行许可。
        </li>
    </ul>
</div>

                </div>
            

            
                <ul class="post-tags-box">
                    
                        <li class="tag-item">
                            <a href="/tags/Docker/">#Docker</a>&nbsp;
                        </li>
                    
                </ul>
            

            

            
                <div class="article-nav">
                    
                        <div class="article-prev">
                            <a class="prev"
                            rel="prev"
                            href="/2023/06/06/ECMAScript6/"
                            >
                                <span class="left arrow-icon flex-center">
                                    <i class="fa-solid fa-chevron-left"></i>
                                </span>
                                <span class="title flex-center">
                                    <span class="post-nav-title-item">ECMAScript6</span>
                                    <span class="post-nav-item">上一篇</span>
                                </span>
                            </a>
                        </div>
                    
                    
                        <div class="article-next">
                            <a class="next"
                            rel="next"
                            href="/2023/06/02/RabbitMQ/"
                            >
                                <span class="title flex-center">
                                    <span class="post-nav-title-item">RabbitMQ</span>
                                    <span class="post-nav-item">下一篇</span>
                                </span>
                                <span class="right arrow-icon flex-center">
                                    <i class="fa-solid fa-chevron-right"></i>
                                </span>
                            </a>
                        </div>
                    
                </div>
            


            
                <div class="comment-container">
                    <div class="comments-container">
    <div id="comment-anchor"></div>
    <div class="comment-area-title">
        <i class="fa-solid fa-comments"></i>&nbsp;评论
    </div>
    

        
            
    <div id="gitalk-container"></div>
    <script data-pjax
            src="//cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.js"></script>
    <script data-pjax>

        function loadGitalk() {
            let __gitalk__pathname = decodeURI(location.pathname);
            const __gitalk__pathnameLength = __gitalk__pathname.length;
            const __gitalk__pathnameMaxLength = 50;
            if (__gitalk__pathnameLength > __gitalk__pathnameMaxLength) {
                __gitalk__pathname = __gitalk__pathname.substring(0, __gitalk__pathnameMaxLength - 3) + '...';
            }

            try {
                Gitalk && new Gitalk({
                    clientID: '55bad54a77b7e60ad62d',
                    clientSecret: '1031c81500c6be06e338087cb7b713f2d0201b46',
                    repo: 'wait-you.github.io',
                    owner: 'wait-you',
                    admin: ['wait-you'],
                    id: 'comment',
                    language: 'zh-CN'
                }).render('gitalk-container');

            } catch (e) {
                window.Gitalk = null;
            }
        }

        if ('true') {
            const loadGitalkTimeout = setTimeout(() => {
                loadGitalk();
                clearTimeout(loadGitalkTimeout);
            }, 1000);
        } else {
            window.addEventListener('DOMContentLoaded', loadGitalk);
        }
    </script>



        
    
</div>

                </div>
            
        </div>

        
            <div class="toc-content-container">
                <div class="post-toc-wrap">
    <div class="post-toc">
        <div class="toc-title">此页目录</div>
        <div class="page-title">Docker</div>
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#docker"><span class="nav-text"> Docker</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#docker%E6%A6%82%E8%BF%B0"><span class="nav-text"> Docker 概述</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#docker%E4%B8%BA%E4%BB%80%E4%B9%88%E4%BC%9A%E5%87%BA%E7%8E%B0"><span class="nav-text"> Docker 为什么会出现</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#docker%E7%9A%84%E5%8E%86%E5%8F%B2"><span class="nav-text"> Docker 的历史</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%B9%E5%99%A8vs%E8%99%9A%E6%8B%9F%E6%9C%BA"><span class="nav-text"> 容器 vs 虚拟机</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#docker%E5%AE%89%E8%A3%85"><span class="nav-text"> Docker 安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#docker%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%BB%84%E6%88%90"><span class="nav-text"> Docker 的基本组成</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%8E%AF%E5%A2%83%E5%87%86%E5%A4%87"><span class="nav-text"> 环境准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%89%E8%A3%85xshell"><span class="nav-text"> 安装 xshell</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#centos%E5%AE%89%E8%A3%85"><span class="nav-text"> Centos 安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8D%B8%E8%BD%BD%E6%97%A7%E7%9A%84%E7%89%88%E6%9C%AC"><span class="nav-text"> 卸载旧的版本</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%89%E8%A3%85%E5%9F%BA%E6%9C%AC%E7%8E%AF%E5%A2%83"><span class="nav-text"> 安装基本环境</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%AE%BE%E7%BD%AE%E9%95%9C%E5%83%8F%E7%9A%84%E4%BB%93%E5%BA%93"><span class="nav-text"> 设置镜像的仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%89%E8%A3%85docker%E5%BC%95%E6%93%8E"><span class="nav-text"> 安装 docker 引擎</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%90%AF%E5%8A%A8docker"><span class="nav-text"> 启动 Docker</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8D%B8%E8%BD%BDdocker"><span class="nav-text"> 卸载 Docker</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%98%BF%E9%87%8C%E4%BA%91%E9%95%9C%E5%83%8F%E5%8A%A0%E9%80%9F"><span class="nav-text"> 阿里云镜像加速</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%BA%95%E5%B1%82%E5%8E%9F%E7%90%86"><span class="nav-text"> 底层原理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#docker%E5%91%BD%E4%BB%A4"><span class="nav-text"> Docker 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B8%AE%E5%8A%A9%E5%91%BD%E4%BB%A4"><span class="nav-text"> 帮助命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%95%9C%E5%83%8F%E5%91%BD%E4%BB%A4"><span class="nav-text"> 镜像命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%B9%E5%99%A8%E5%91%BD%E4%BB%A4"><span class="nav-text"> 容器命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E5%85%B6%E4%BB%96%E5%91%BD%E4%BB%A4"><span class="nav-text"> 常用其他命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%AF%E8%A7%86%E5%8C%96"><span class="nav-text"> 可视化</span></a></li><li class="nav-item nav-level-3"><a class="nav-link"><span class="nav-text"> </span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#docker%E9%95%9C%E5%83%8F"><span class="nav-text"> Docker 镜像</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8E%9F%E7%90%86"><span class="nav-text"> 原理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#commit%E6%8F%90%E4%BA%A4%E9%95%9C%E5%83%8F"><span class="nav-text"> commit 提交镜像</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%B9%E5%99%A8%E6%95%B0%E6%8D%AE%E5%8D%B7"><span class="nav-text"> 容器数据卷</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E5%AE%B9%E5%99%A8%E5%8D%B7"><span class="nav-text"> 什么是容器卷</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8%E6%95%B0%E6%8D%AE%E5%8D%B7"><span class="nav-text"> 使用数据卷</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%9E%E6%88%98%E5%AE%89%E8%A3%85mysql"><span class="nav-text"> 实战安装 mysql</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%B7%E5%90%8D%E5%92%8C%E5%8C%BF%E5%90%8D%E6%8C%82%E8%BD%BD"><span class="nav-text"> 具名和匿名挂载</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#-2"><span class="nav-text"> </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%9A%E4%B8%AA%E5%AE%B9%E5%99%A8%E6%95%B0%E6%8D%AE%E5%85%B1%E4%BA%AB"><span class="nav-text"> 多个容器数据共享</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#dockerfile"><span class="nav-text"> DockerFile</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%98%E6%96%B9dockerfile%E7%A4%BA%E4%BE%8B"><span class="nav-text"> 官方 DockerFile 示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#dockerfile%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86"><span class="nav-text"> DockerFile 基础知识</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#dockerfile%E5%91%BD%E4%BB%A4"><span class="nav-text"> DockerFile 命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#-3"><span class="nav-text"> </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%9E%E6%88%98%E6%9E%84%E5%BB%BA%E8%87%AA%E5%B7%B1%E7%9A%84centos"><span class="nav-text"> 实战构建自己的 centos</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#cmd%E4%B8%8Eentrypoint"><span class="nav-text"> CMD 与 ENTRYPOINT</span></a></li></ol></li></ol></li></ol>

    </div>
</div>
            </div>
        
    </div>
</div>


                

            </div>
            
            

        </div>

        <div class="main-content-footer">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info">
            &copy;
            
              <span>2022</span>
              -
            
            2023&nbsp;&nbsp;<i class="fa-solid fa-heart fa-beat" style="--fa-animation-duration: 0.5s; color: #f54545"></i>&nbsp;&nbsp;<a href="/">meteor</a>
        </div>
        
            <script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    <span id="busuanzi_container_site_uv" class="busuanzi_container_site_uv">
                        访问人数&nbsp;<span id="busuanzi_value_site_uv" class="busuanzi_value_site_uv"></span>
                    </span>
                
                
                    <span id="busuanzi_container_site_pv" class="busuanzi_container_site_pv">
                        总访问量&nbsp;<span id="busuanzi_value_site_pv" class="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="theme-info info-item">
            <span class="powered-by-container">由 <?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="圖層_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1rem" height="1rem" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve"><path fill="#0E83CD" d="M256.4,25.8l-200,115.5L56,371.5l199.6,114.7l200-115.5l0.4-230.2L256.4,25.8z M349,354.6l-18.4,10.7l-18.6-11V275H200v79.6l-18.4,10.7l-18.6-11v-197l18.5-10.6l18.5,10.8V237h112v-79.6l18.5-10.6l18.5,10.8V354.6z"/></svg><a target="_blank" href="https://hexo.io">Hexo</a> 驱动</span>
                <br>
            <span class="theme-version-container">主题&nbsp;<a class="theme-version" target="_blank" href="https://github.com/EvanNotFound/hexo-theme-redefine">Redefine v2.1.4</a>
        </div>
        
            <div class="icp-info info-item"><a target="_blank" rel="nofollow" href="
                
                    beian.miit.gov.cn
                
                ">冀ICP备20010108号</a></div>
        
        
        
            <div id="start_div" style="display:none">
                2022/8/17 11:45:14
            </div>
            <div>
                博客已运行 <span class="odometer" id="runtime_days" ></span> 天 <span class="odometer" id="runtime_hours"></span> 小时 <span class="odometer" id="runtime_minutes"></span> 分钟 <span class="odometer" id="runtime_seconds"></span> 秒
            </div>
        
        
        
            <script async data-pjax>
                try {
                    function odometer_init() {
                    const elements = document.querySelectorAll('.odometer');
                    elements.forEach(el => {
                        new Odometer({
                            el,
                            format: '( ddd).dd',
                            duration: 200
                        });
                    });
                    }
                    odometer_init();
                } catch (error) {}
            </script>
        
        
        
    </div>  
</footer>
        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="article-tools-list">
        <!-- TOC aside toggle -->
        
            <li class="right-bottom-tools page-aside-toggle">
                <i class="fa-regular fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
            <li class="go-comment">
                <i class="fa-regular fa-comments"></i>
            </li>
        
    </ul>
</div>

        </div>
    

    <div class="right-side-tools-container">
        <div class="side-tools-container">
    <ul class="hidden-tools-list">
        <li class="right-bottom-tools tool-font-adjust-plus flex-center">
            <i class="fa-regular fa-magnifying-glass-plus"></i>
        </li>

        <li class="right-bottom-tools tool-font-adjust-minus flex-center">
            <i class="fa-regular fa-magnifying-glass-minus"></i>
        </li>

        <li class="right-bottom-tools tool-expand-width flex-center">
            <i class="fa-regular fa-expand"></i>
        </li>

        <li class="right-bottom-tools tool-dark-light-toggle flex-center">
            <i class="fa-regular fa-moon"></i>
        </li>

        <!-- rss -->
        

        

        <li class="right-bottom-tools tool-scroll-to-bottom flex-center">
            <i class="fa-regular fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="visible-tools-list">
        <li class="right-bottom-tools toggle-tools-list flex-center">
            <i class="fa-regular fa-cog fa-spin"></i>
        </li>
        
            <li class="right-bottom-tools tool-scroll-to-top flex-center">
                <i class="arrow-up fas fa-arrow-up"></i>
                <span class="percent"></span>
            </li>
        
        
    </ul>
</div>

    </div>

    <div class="image-viewer-container">
    <img src="">
</div>


    


</main>




<script src="/js/utils.js"></script>

<script src="/js/main.js"></script>

<script src="/js/layouts/navbarShrink.js"></script>

<script src="/js/tools/scrollTopBottom.js"></script>

<script src="/js/tools/lightDarkSwitch.js"></script>





    
<script src="/js/tools/codeBlock.js"></script>




    
<script src="/js/layouts/lazyload.js"></script>




    
<script src="/js/tools/runtime.js"></script>

    
<script src="/js/layouts/odometer.min.js"></script>

    
<link rel="stylesheet" href="/assets/odometer-theme-minimal.css">




  
<script src="/js/libs/Typed.min.js"></script>

  
<script src="/js/plugins/typed.js"></script>







<div class="post-scripts pjax">
    
        
<script src="/js/tools/tocToggle.js"></script>

<script src="/js/libs/anime.min.js"></script>

<script src="/js/layouts/toc.js"></script>

<script src="/js/plugins/tabs.js"></script>

    
</div>


    
<script src="/js/libs/pjax.min.js"></script>

<script>
    window.addEventListener('DOMContentLoaded', () => {
        window.pjax = new Pjax({
            selectors: [
                'head title',
                '.page-container',
                '.pjax',
            ],
            history: true,
            debug: false,
            cacheBust: false,
            timeout: 0,
            analytics: false,
            currentUrlFullReload: false,
            scrollRestoration: false,
            // scrollTo: true,
        });

        document.addEventListener('pjax:send', () => {
            Global.utils.pjaxProgressBarStart();
        });

        document.addEventListener('pjax:complete', () => {
            Global.utils.pjaxProgressBarEnd();
            window.pjax.executeScripts(document.querySelectorAll('script[data-pjax], .pjax script'));
            Global.refresh();
        });
    });
</script>




</body>
</html>
